Multiple choice technology programming languages

Contents in AQuestion.java private class AQuestion { public void method(Object o){ System.out.println("Object Verion"); } public void method(String s){ System.out.println("String Version"); } public static void main(String args[]){ AQuestion question = new AQuestion(); question.method(null); } }

  1. The code does not compile.

  2. The code compiles cleanly and shows “Object Version”.

  3. The code compiles cleanly and shows “String Version”

  4. The code throws an Exception at Runtime.

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

In Java, a top-level class cannot be private - only public, abstract, and final are allowed. The code attempts to declare "private class AQuestion" which violates this rule. Therefore, the code does not compile. If it were a valid inner class, the overload resolution would select the more specific String method for null argument.