Multiple choice technology programming languages

What is the output for the below code ? public class Outer { private int a = 7; class Inner { public void displayValue() { System.out.println("Value of a is " + a); } } } public class Test { public static void main(String... args) throws Exception { Outer mo = new Outer(); Outer.Inner inner = mo.new Inner(); inner.displayValue(); } }

  1. Value of a is 7

  2. Compile Error - not able to access private member.

  3. Runtime Exception

  4. Value of a is 8

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

In Java, a non-static inner class holds an implicit reference to its enclosing outer class instance. Consequently, inner classes can directly access all members of the outer class, including those declared with private access modifiers, allowing the display of a as 7.