You can assign a null value to any reference variable. But the null value is not an instanceof Object or any other class. When you assign a reference variable null, it means that the reference variable doesn't refer to any object.
Also this has been asked to you
earlier by Christophe and I'm saying it again, try to ask the problem outside of the code. Instead of your question in the code itself, you can give the line that you are confused in a number and ask the question relative to that line number. Eg.
At line (2) I am able to return null here, the compiler doesnt complain. However when i do instanceOf Object at line (1) it doesnt enter the if loop. How is this possible ?