📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    If a program crashes with a "NullPointerException" (or

    similar null reference error), what is the most likely cause?
    A Division by zero. Correct Answer Incorrect Answer
    B Attempting to access a member or method of an object that is currently null. Correct Answer Incorrect Answer
    C Infinite loop. Correct Answer Incorrect Answer
    D Stack overflow. Correct Answer Incorrect Answer
    E Incorrect array indexing. Correct Answer Incorrect Answer

    Solution

    A NullPointerException occurs when a program tries to use an object reference that currently points to null (meaning no object) as if it were a valid object. This typically happens when trying to call a method on a null reference or access a field of a null reference.

    Practice Next
    ask-question