Multiple choice java

Which variables have the longest scope?

  1. Block variables

  2. Instance variables

  3. Static variables

  4. Local variables

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

Static variables (class variables) are created when the class is loaded and persist until the program ends - they have the longest scope. Instance variables exist only as long as the object exists. Local (method) variables exist only during method execution. Block variables have the narrowest scope, existing only within their code block.