Hi,
I found this example in JLS 8.4.8.5.I still couldn't able to understand why the output is "Goodnight, Dick" instead of "Hello Dick".
It would be more helpful if you could give me a detailed explanation.
<h4>
<code>
class Super {
static
String greeting() { return "Goodnight"; }
String name() { return "Richard"; }
}
class Sub extends Super {
static String greeting() { return "Hello"; }
String name() { return "Dick"; }
}
class
Test {
public static void main(String[] args) {
Super s = new Sub();
System.out.println(s.greeting() + ", " + s.name());
}
}
produces the output:
Goodnight, Dick
</code>
</h4>
Thanks
Balaji
[This message has been edited by Balaji Loganathan (edited July 22, 2001).]