Skip to content

Commit 41fdca4

Browse files
committed
Update java-multiple-choice-questions-answers.md
1 parent 7e9569a commit 41fdca4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

java-multiple-choice-questions-answers.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,4 +212,22 @@ A. double num1, int num2 = 0;
212212
213213
Explanation: A. Option A does not compile because Java does not allow declaring different types as
214214
part of the same declaration.
215+
```
216+
#### Q. What is the output of the following?
217+
public static void main(String... args) {
218+
String chair, table = "metal";
219+
chair = chair + table;
220+
System.out.println(chair);
221+
}
222+
A. metal
223+
B. metalmetal
224+
C. nullmetal
225+
D. The code does not compile
226+
```
227+
D. The code does not compile
228+
229+
Explanation: Exception in thread "main" java.lang.Error: Unresolved compilation problem:
230+
The local variable chair may not have been initialized
231+
232+
at Test.main(Test.java:7)
215233
```

0 commit comments

Comments
 (0)