Why doesn't calling a static variable chained from a static method that returns null throw a NPE?

Viewed 275

I have the following code

public class Test {
    static String mountain = "Everest";

    static Test favorite() {
        System.out.print("Mount ");
        return null;
    }

    public static void main(String[] args) {
        System.out.println(favorite().mountain);
    }
}

I thought it would raise a NPE but it is giving Mount Everest as output can anyone clarify?

3 Answers
Related