because get(Object o) is not overridden by get(String o). Instead the two methods are overloaded. So when you call get("super") with a SuperCafe4Java class reference, the compiler looks for a method matching get("super") in the SuperCafe4Java class. It finds the get(Object o) method matching this method (as get(String o) is not available in SuperCafe4Java). So that method is called.
Here get() method of SuperCafe4Java is overloaded in the sub class SubCafe4Java. Its not overridden.(Overridden method calls will be determined at run time) And the calls to the overloaded methods will be determined at compile time.
So the get method in SuperCafe4Java will be executed not the one in SubCafe4Java.
See page 109 of K&B 5.0 for more info!
Hope this is clear!
Thanks,<br />Srilatha M
Joined: Sep 20, 2008
But When Im Running This Two Code...Getting Different OutPut