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

Java Miscellaneous

Advanced Java

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

Answer : C

Explaination

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

Q 2 - What is the size of short variable?

A - 8 bit

B - 16 bit

C - 32 bit

D - 64 bit

Answer : B

Explaination

The short data type is represented by 16-bit signed two's complement integer.

Minimum value: -32,768

Maximum value: 32,767

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

A - 0

B - 0.0

B - null

B - undefined

Answer : A

Explianation

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

Q 5 - A class always has a default constructor.

A - True

B - False

Answer : B

Explaination

It is not mandatory to have a default constructor in a class.

Answer : A

Explaination

Static binding occurs during Compile time.

Q 8 - Does garbage collection guarantee that a program will not run out of memory?

A - True.

B - False.

Answer : B

Explaination

Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Answer : B

Explaination

Program throws "NoSuchMethodError" error at runtime.

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