Multiple choice technology programming languages

Following code will result in: class A { int b = 1; public static void main(String [] args) { System.out.println("b is " + b); }}

  1. Compilation error

  2. Runtime Error

  3. Runtime Exception

  4. Output of b is 1

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

The variable 'b' is an instance variable (non-static), but main() is a static method. Static methods cannot directly access instance members without creating an object instance first. This causes a compilation error: 'non-static variable b cannot be referenced from a static context.'