Thursday, 14 September 2017

Statics in Java

This one comes straight out of the Java Language Specification1, paragraph 15.12.4.1:
class Test1 { 
    static void mountain() 
    { 
        System.out.println("Monadnock"); 
    } 

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

    public static void main(String[] args) 
    { 
        favorite().mountain(); 
    } 
}
What is the output of this program?

References

[1] The Java Language Specification, Java SE 8 Edition
https://docs.oracle.com/javase/specs/

No comments:

Post a Comment