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 - Which of the following is not a keyword in java?

A - static

B - Boolean

C - void

C - private

Answer : B

Explaination

Boolean is a class and is not a keyword.

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 short variable?

A - 0.0

B - 0

B - null

B - undefined

Answer : B

Explaination

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

Answer : C

Explaination

String is a object.

Answer : C

Explaination

Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded.

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 : 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

Deserialization is the process of restoring state of an object from a byte stream.

Q 9 - Can a top level class be private or protected?

A - True.

B - False.

Answer : B

Explaination

No, a top level class can not be private or protected. It can have either "public" or no modifier.

Q 10 - Which of the following is a thread safe?

A - StringBuilder

B - StringBuffer

C - Both of the above

D - none of the above

Answer : B

Explaination

StringBuffer is thread safe.


java_questions_answers.htm

Advertisements