<code>if (x > 0) { int y = 10; } System.out.println(y); </code></pre>
- A
Prints 10
- B
Prints 0
- Ccheck_circle
Compile error: y out of scope
- D
Prints undefined
Explanation
<code>y</code> declared in the if block scope; not visible outside.
AP Computer Science A· difficulty 4/5
<code>if (x > 0) { int y = 10; } System.out.println(y); </code></pre>
Prints 10
Prints 0
Compile error: y out of scope
Prints undefined
Explanation
<code>y</code> declared in the if block scope; not visible outside.
Want 10 more like this — adaptive to your weak spots?