Java Online Quiz


Advertisements


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 an instance variable?

A - null

B - 0

C - Depends upon the type of variable

D - Not assigned

Answer : C

Explaination

Instance variables are assigned default values based on their types. For example, int variable is assigned 0 and an object type variable is assigned null as default value.

Q 2 - Can we have multiple classes in same java file?

A - True

B - False

Answer : A

Explaination

True, a java file can contain one public class and many other non-public classes.

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

A - 0

B - 0.0

C - null

D - not defined

Answer : A

Explaination

Byte variable has default value of 0 if defined as an instance/static variable.

Answer : A

Explaination

It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.

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

Explaination

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

Answer : B

Explaination

A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization.

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 - This is the parent of Error and Exception classes.

A - Throwable

B - Catchable

C - MainError

D - MainException

Answer : A

Explaination

Throwable is the parent of both Error and Exception class.


java_questions_answers.htm

Advertisements