Home
MCQs
Java MCQs
All MCQs
Java MCQs

Java MCQs - All MCQs

History, JVM, JRE and JDK, Variables, Data Types, Operators, Control Statements, Iterative Statements, Object Class, Naming conventions, Constructors

1. What the naming convention should be for Class in Java?

A. It should start with the uppercase letter.

B. It should be a noun such as Student, School, Book

C. Use appropriate words, instead of acronyms.

D. All of above

Answer: D

2. Where to declare instance variables ?

A. It declares inside the class and outside of method.

B. It declares inside the class with static prefix and outside of method.

C. It declares inside the method.

Answer: A

3. Identity characteristic of an object represents

A. the data of an object

B. the behaviors or actions of an object

C. the internal unique identity of an object

D. All of above

Answer: C

4. Which are the bitwise operators ?

A. &

B. ^

C. |

D. All of Above

Answer: D

5. Java naming convention is a suggestion only to follow

A. true

B. false

Answer: A

6. What is the default size of double ?

A. 1 byte

B. 2 bytes

C. 4 bytes

D. 8 bytes

Answer: D

7. What is the right output of this program ?

A. true

B. false

C. Hello 1

D. Hello 2

Answer: C

8. What the naming convention should be for Constants in Java?

A. It should be in uppercase letters such as DAY, MONTH

B. If the name contains multiple words, it should be separated by an underscore(_) such as FINAL_DATE.

C. It may contain digits but not as the first letter

D. All of above

Answer: D

9. What is the return value of constructor in java?

A. 1

B. null

C. void

D. instance

Answer: D

10. What is Java Virtual Machine (JVM)?

A. It is a physical machine and a specification which provides runtime environment for java bytecode execution.

B. It is an abstract machine and a specification which provides runtime environment for java bytecode execution.

C. It is a abstract machine and a implementation which provides runtime environment for java sourcecode compilation.

D. It is a physical machine and a implementation which provides runtime environment for java sourcecode compilation.

Answer: B