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

A - 8 bit

B - 16 bit

C - 32 bit

D - 64 bit

Answer : C

Explaination

The int data type is represented by 32-bit signed two's complement integer,

Minimum value: -231

Maximum value: 231-1

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

A - 0

B - 0.0

C - 0L

D - not defined

Answer : C

Explaination

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

Answer : C

Explaination

By default, variables, methods and constructors can be accessed by any class lying in the same package.

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.

Q 7 - Static binding uses which information for binding?

A - type.

B - object.

C - Both of the above.

D - None of the above.

Answer : A

Explaination

Static binding uses type information for binding.

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 - Can try statements be nested?

A - True.

B - False.

Answer : A

Explaination

Yes, try statements be nested.

Q 10 - which operator is considered to be with highest precedence?

A - () , []

B - =

C - ?:

D - %

Answer : A

Explaination

Postfix operators i.e () [] . is at the highest precedence.

java_questions_answers.htm
Advertisements