public class JavaPuzzler { public static void main(String[] args) { JavaPuzzler javaPuzzler = null; System.out.println(javaPuzzler.get()); } private static String get(){ return "i am a java puzzler"; }}
You might think that it should throw NullPointerException because the main method invokes get() method on local variable which is initializedto null, and you can’t invoke a method on null.
But if you run this program, you will see that it prints “i am a java puzzler”.