Java Tutorial

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 List Interface

Java Queue Interface

Java Map Interface

Java Set Interface

Java Data Structures

Java Collections Algorithms

Advanced Java

Java Miscellaneous

Java APIs & Frameworks

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 - Can we compare int variable with a boolean variable?

A - True

B - False

Answer : B

Explaination

True, Compile time error will occur if an int variable is compared with Boolean variable.

Q 2 - What is the size of long variable?

A - 8 bit

B - 16 bit

C - 32 bit

D - 64 bit

Answer : D

Explaination

The long data type is represented by 64-bit two's complement integer.

Minimum value: -263

Maximum value: 263-1

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

Explaination

An immutable object can't be changed once it is created. String objects are immutable.

Q 6 - Can be constructor be made final?

A - True.

B - False.

Answer : B

Explaination

No, this is not possible.

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

Explaination

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

Q 9 - Is it necessary that each try block must be followed by a catch block?

A - True.

B - False.

Answer : B

Explaination

It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.

Q 10 - Which of the following is Faster, StringBuilder or StringBuffer?

A - StringBuilder

B - StringBuffer

C - Both of the above.

D - none of the above.

Answer : A

Explaination

StringBuilder is faster than StringBuffer.

java_questions_answers.htm
Advertisements