JAVA Programming :: Objects and Classes

Home > JAVA Programming > Objects and Classes > General Questions

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

1 / 30

 Which statement is true?

AAn abstract class can be extended by an interface.

BAn interface CANNOT be extended by another interface.

CAn interface can be extended by an abstract class.

DAn abstract class can be extended by a concrete class.

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

2 / 30

 Which declaration of the main method below would allow a class to be started as a standalone program. Select the one correct answer.

Apublic static int main(char args[])

Bpublic static void main(String args[])

Cpublic static void MAIN(String args[])

Dpublic static void main(String args)

Epublic static void main(char args[])

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

3 / 30

 If we do
ArrayList lst = new ArrayList();
What is the initial capacity of the ArrayList lst ?

A10

B8

C15

D12

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

4 / 30

 An sequence diagram is:

AA time-line illustrating a typical sequence of calls between object function members

BA call tree illustrating all possible sequences of calls between class function members

CA time-line illustrating the changes in inheritance and instantiation relationships between classes and objects over time

DA tree illustrating inheritance and relationships between classes

EA directed acyclic graph illustrating inheritance and instantiation relationships between classes and objects

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

5 / 30

 To make a variable defined in a class accessible only to methods defined in the classes in same package, which of the following keyword should be used. Select the one correct answer.

ABy using the keyword private before the variable.

BBy using the keyword protected before the variable.

CBy using the keyword public before the variable.

DThe variable should not be preceded by any of the above mentioned keywords.

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

6 / 30

 Which is a valid definition of an interface called Transportable given another valid interface, Movable?

Aclass Movable extends Transportable { /*…*/ }

Binterface Transportable extends Movable { /*…*/ }

Cclass Movable implements Transportable { /*…*/ }

Dinterface Transportable implements Movable { /*…*/ }

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

7 / 30

 Which statement is true?

AAn abstract class can be extended by an interface.

BAn interface CANNOT be extended by another interface.

CAn interface can be extended by an abstract class.

DAn abstract class can be extended by a concrete class.

Answer: Option D

Explanation:

Here is no explanation for this answer

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

8 / 30

 Which of the following modifier cannot be applied to the declaration of a field (Member of a class)?

Aprotected

Bprivate

Cfinal

Dabstract

Answer: Option D

Explanation:

abstract

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

9 / 30

 A programmer is designing a class to encapsulate the information about an inventory item.
A JavaBeans component is needed to do this.
The InventoryItem class has private instance variables to store the item information :
private int itemId;
Which method signature follows the JavaBeans naming standards for modifying the itemId instance variable ?

AitemId(int itemId)

Bupdate(int itemId)

CsetItemId(int itemId)

DmutateItemId(int itemI

EupdateItemId(int itemId)

Answer: Option C

Explanation:

setItemId(int itemId)

Workspace

NA
SHSTTON
0
Solv. Corr.
0
Solv. In. Corr.
0
Attempted
0 M:0 S
Avg. Time

10 / 30

 Which of the following is true.

AA class that is abstract may not be instantiate

BThe final keyword indicates that the body of a method is to be found elsewher The code is written in non-Java language, typically in C/C++.

CA static variable indicates there is only one copy of that variable

DA method defined as private indicates that it is accessible to all other classes in the same packag

EBoth A & C

Answer: Option E

Explanation:

Here is no explanation for this answer

Workspace