Will this Java code run? The Test instance variable via the value() method returns null. What about NullPointerException? Is it possible to access the pi member through null?
public class Test {
static float pi = 3.14f;
Test value() {
return null;
}
public static void main(String args[]) {
final Test test = new Test();
System.out.println(test.value().pi);
}
}
Yes, definitely. The return type of the value() method is Test type, so you can safely access all static members.