Should the equals() method return 'true' if two objects are null.
No that would give you a null pointer exception because you are trying to invoke a method on null. Like null.equals().
Secondly I don't think in your code o is null. I guess the reference variable that you are calling equals() on is null. Had o been null it would not had thrown a null pointer exception but would had returned false. As this would
... code gives NullPointerException if 'o' is null. Should the equals() method return 'true' if two objects are null.
One rule of equals() says, under all circumstances a.equals(null) ==false
Where ofcource "a" can't be null, otherwise NullPointerException.
And it is the matter of thinking for a while, how can you even call the equals method to compare two nulls. You can't call a method using a reference variable that is null. So no chance to even reach the inside the equals method code.
null is fortunate enough to be passed anywhere where reference is required and it never means that it can dare to break the rules.