call static method on null object

Give the code first, guess the result
public class TestClass {
	private static void staticMethod(){
		System.out.println("static");
	}
	void normalMethod(){
		System.out.println("normal");
	}
	public static void main(String[] args) {
		TestClass testClass=((TestClass)null);
		testClass.staticMethod();
		testClass.normalMethod();
	}
}

I thought that a NullPointerException would be reported at the beginning
and the staticMethod() was actually executed. . .
The summary is as follows:
1.null can be casted to any object 2.null can be
casted to an object after calling the static method of the class without error

mark for reference

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042512&siteId=291194637