For a given non-null String myTestVariable
, what is the resulting value of executing the statement myTestVariable
.equals(null)?
B.
The statement compiles and runs without issue, making Options C and D incorrect.
Since we are given that myTestVariable
is not null, the statement will always evaluate to false, making Option B the correct answer.
If myTestVariable
was null, then the code would still compile but throw a NullPointerException calling equals()
at runtime.