What does null mean in Java, and what is a NullPointerException?
Options
nullmeans no object is referenced; using it throws NullPointerException (Correct option)nullequals zero; the exception appears when dividing by zeronullis an empty string; the exception happens on empty stringsnullis a keyword that marks the end of a loop
Answer
null means a reference points to no object; calling a method on it throws a NullPointerException
Why
A variable that holds an object really holds a reference (an address). null means 'no object'.
String s = null; s.length(); crashes with NullPointerException (NPE), because there is no object to ask for its length.
Typical fixes: check for null, initialize variables, or use Optional to make 'maybe nothing' explicit.
Remember
null = no object. Using it as an object → NPE.