Multiple choice technology programming languages

Read the code below. Will be the result of attempting to compile and run the code below. public 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
C Correct answer
Explanation

When method overloading exists with null argument, Java chooses the most specific method. Since String extends Object, the String version is more specific than Object version. The compiler resolves null to the String overload at compile-time. The code compiles cleanly and prints 'String Version'. This is a classic Java overload resolution rule.