This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff 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!