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

Answer : C

Explaination

Correct syntax is public static void main(String[] args).

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

A - ""

B - ''

C - null

D - not defined

Answer : C

Explaination

String variable has default value of null if defined as an instance/static variable.

Answer : B

Explaination

String object is immutable so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads which are considered very important for multithreaded programming.

Answer : C

Explaination

It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also referred to as data hiding.

Q 6 - Can be constructor be made final?

A - True.

B - False.

Answer : B

Explaination

No, this is not possible.

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

Serialization is the process of writing the state of an object to a byte stream.

Q 9 - Which arithmetic operations can result in the throwing of an ArithmeticException?

A - / , %

B - * , +

C - ! , -

D - >>, <<

Answer : A

Explaination

Integer / and % can result in the throwing of an ArithmeticException.

java_questions_answers.htm
Advertisements