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

111. 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

112. Where to declare local 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: C

113. What is the output of this program?

A. 0 default value

B. Compile time error - Instance variable may not have been initialized

C. Run time error - Instance variable may not have been initialized

D. None of Above

Answer: A

114. An object can be initialize in Java by?

A. reference variable

B. method

C. constructor

D. All of above

Answer: D

115. What is the correct output of this program ?

A. If condition true

B. Else true

C. Both of above

Answer: A

116. Which is the right naming convention for method in Java?

A. void DrawShape()

B. void draw_shape()

C. void drawShape()

D. All of above

Answer: C

117. What is the correct output of this program ?

A. 1 2 3 4 5 6 7 8 9 10

B. 0 1 2 3 4 5 6 7 8 9 10

C. 1 2 3 4 5 6 7 8 9 10 11

D. None of above

Answer: A

118. When the Java language project initiated?

A. June 1991

B. April 1995

C. Jan 1996

D. Feb 1997

Answer: A

119. What is the default value of boolean?

A. true

B. false

C. '1'

D. '0'

Answer: B

120. What is the correct output of this program ?

A. 2 4 6 8 10

B. Compile time error

C. Infinite Loop

D. None

Answer: A