Multiple choice technology architecture

public class NumbPlay { int x=5; public static void main(String[] args) { new NumbPlay().doPlay(); } void doPlay() { int x; System.out.println(++x); } } The output is

  1. 5

  2. 6

  3. Compile error

  4. Runtime error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Local variables in Java must be initialized before use. The code declares 'int x' in doPlay() but doesn't assign it a value before using '++x'. This causes a compile-time error. The instance variable 'x=5' is shadowed by the local declaration and is not accessed.