This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
This has been asked many times. The compiler chooses the most specific method for the job and here the most specific is the one that takes String argument. The rule for choosing the most specific method is that, one method is more specific than the other if any argument that the methodtakes can be easily passed to the other method without any compilation errors. Here any argument that you can pass to a String can be passed to the method that takes Object as argument. But the vice versa is not true. Hence you get this O/P as String.
Hope this helps.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!