Multiple choice technology programming languages

What is true about null?

  1. You can call a method on null: x.m() will not throw an error when x is null and m is a static method.

  2. null instanceof Object returns true

  3. You can pass null as the literal argument to a constructor of an anonymous inner class. e.g., new SomeClass(null) { }

  4. None of above

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

When you call a static method on a null reference (x.m() where x is null and m is static), Java doesn't throw NullPointerException because static methods are bound to the class, not the instance. The other options are false: null instanceof Object is false, and passing null to anonymous inner class constructor is generally problematic.