Why this code DOES NOT return a NullPointerException?

java, nullpointerexception

Solution

It behaves as it should according to the Java Language Specification:

a null reference may be used to access a class (static) variable without causing an exception.

Problem

``` public class Main { public static void main(String []ar) { A m = new A(); System.out.println(m.getNull().getValue()); } } class A { A getNull() { return null; } static int getValue() { return 1; } } ``` I came across this question in an SCJP book. The code prints out `1` instead of an NPE as would be expected. Could somebody please explain the reason for the same?

Original source