Multiple choice technology programming languages

What will be the output of the below code snippet? public class Quiz8 { class Base { public String className = "Base"; } class Derived extends Base { private String className = "Derived"; } public static void main(String[] args) { System.out.println(new Derived().className); } }

  1. Derived

  2. Compilation Error in Main mehod

  3. Compilation Error due to Derived class

  4. Run Time Error

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

The code fails to compile in the main method. Since main is static, it cannot instantiate the non-static inner class Derived without an instance of Quiz8. Also, Derived.className is private and cannot be accessed from main directly.