Important Java Mcq 1

What will be the output of the following?

public static void main(String... args) {
   String chair, table = "metal";
   chair = chair + table;
   System.out.println(chair);
}
a) metal
b) metalmetal
c) nullmetal
d) The code does not compile.

Answer:

d) The code does not compile.

Explanation

The local variable chair may not have been initialized.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?