Java Operators

Java Control Statements

Object Oriented Programming

Java Built-in Classes

Java File Handling

Java Error & Exceptions

Java Multithreading

Java Synchronization

Java Networking

Java Collections

Java Interfaces

Java Data Structures

Java Collections Algorithms

Advanced Java

Java Miscellaneous

Java APIs & Frameworks

Java Class References

Java Useful Resources

Java Online Quiz



Following quiz provides Multiple Choice Questions (MCQs) related to Core Java. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - What of the following is the default value of a local variable?

A - null

B - 0

C - Depends upon the type of variable

D - Not assigned

Answer : D

Explaination

Local variables are not assigned any value by default.

Q 2 - Can we have two public classes in one java file?

A - True

B - False

Answer : B

Explaination

No, a java file can contain only one public class.

Q 3 - What is the default value of float variable?

A - 0.0d

B - 0.0f

C - 0

D - not defined

Answer : B

Explaination

float variable has default value of 0.0f if defined as an instance/static variable.

Q 5 - A class always has a default constructor.

A - True

B - False

Answer : B

Explaination

It is not mandatory to have a default constructor in a class.

Q 6 - 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

Method Overriding is example of dynamic Binding.

Q 8 - Does garbage collection guarantee that a program will not run out of memory?

A - True.

B - False.

Answer : B

Explaination

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Q 9 - Deletion is faster in LinkedList than ArrayList.

A - True.

B - False.

Answer : A

Explaination

Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.

Q 10 - Which method must be implemented by all threads?

A - wait()

B - start()

C - stop()

D - run()

Answer : D

Explaination

All threads must implement the run() method.

java_questions_answers.htm
Advertisements