Which exception occurs if a null object is accessed?

  1. IllegalArgumentException
  2. IllegalStateException
  3. NullPointerException
  4. ObjectAccessException
Correct answer NullPointerException

Explanation

Accessing methods or members of a null object causes `NullPointerException`.

Update: Admin added a tag on this question

Topics

By Admin · · 29 views