Java Mock Test


Advertisements

This section presents you various set of Mock Tests related to Java Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Java Mock Test III

Q 1 - Composition represents

A - HAS-A relationship.

B - IS-A relationship.

Answer : A

Explaination

Holding the reference of the other class within some other class is known as composition. It represents a HAS-A relationship. For example, a Student has a Pen. Here Student class has Pen as its instance variable.

Answer : B

Explaination

A class consist of Local variable, instance variables and class variables.

Answer : A

Explaination

An applet is a Java program that runs in a Web browser.

Answer : C

Explaination

Set is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.

Answer : C

Explaination

Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application.

Answer : A

Explaination

JIT, Just In-Time Compiler, improves the runtime performance of computer programs based on bytecode.

Q 8 - Can be constructor be made final?

A - True.

B - False.

Answer : B

Explaination

No, this is not possible.

Q 9 - Can be constructor be made private?

A - True.

B - False.

Answer : A

Explaination

Yes, class with private constructor can not instantiated using new keyword.

Answer : C

Explaination

static block is used to initialize the static data member.It is executed before main method at the time of loading of a class.

Answer : C

Explaination

Holding the reference of the other class within some other class is known as composition. It represents a HAS-A relationship. For example, a Student has a Pen. Here Student class has Pen as its instance variable.

Answer : A

Explaination

If a class has multiple functions by same name but different parameters, it is known as Method Overloading.

Answer : B

Explaination

If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

Answer : A

Explaination

Static binding occurs during Compile time.

Answer : A

Explaination

Method Overloading is example of static binding.

Q 16 - Static binding uses which information for binding?

A - type.

B - object.

C - Both of the above.

D - None of the above.

Answer : A

Explaination

Static binding uses type information for binding.

Q 17 - Dynamic binding uses which information for binding?

A - type.

B - object.

C - Both of the above.

D - None of the above.

Answer : B

Explaination

Dynamic binding uses object information for binding.

Answer : B

Explaination

Method Overriding is example of dynamic Binding.

Answer : D

Explaination

Final classes are created so the methods implemented by that class cannot be overridden. It can't be inherited. These classes are declared final.

Answer : A

Explaination

A NullPointerException is thrown when calling the instance method of a null object or modifying/accessing field of a null object.

Answer : D

Explaination

A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

Answer : A

Explaination

After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Answer : A

Explaination

When a task invokes its yield() method, it returns to the ready state.

Answer : B

Explaination

When a task invokes its sleep() method, it returns to the waiting state.

Answer : A

Explaination

These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

Answer Sheet

Question Number Answer Key
1 A
2 B
3 A
4 C
5 B
6 C
7 A
8 B
9 A
10 C
11 C
12 A
13 B
14 A
15 A
16 A
17 B
18 B
19 D
20 A
21 D
22 A
23 A
24 B
25 A
java_questions_answers.htm
Advertisements