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 - 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 - What is the size of char variable?

A - 8 bit

B - 16 bit

C - 32 bit

D - 64 bit

Answer : B

Explaination

The char data type is represented by single 16-bit Unicode character.

Minimum value: '\u0000' (or 0)

Maximum value: '\uffff' (or 65,535)

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

Explaination

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

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

Explaination

A NullPointerException is thrown when calling the instance method of a null object or modifying/accessing field of a null object.

Answer : D

Explaination

A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

Q 9 - Can constructor be inherited?

A - True.

B - False.

Answer : B

Explaination

No, constructor cannot be inherited.

java_questions_answers.htm
Advertisements