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.
Answers The code does not compile. The code compiles cleanly and shows "Object Version". The code compiles cleanly and shows "String Version" <<CORRECT ANS>> The code throws an Exception at Runtime. Can anyone Plz explain How Compiler deduced that. Plz also mention the thumbrule for the same
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
Both methods method(Object o) and method(String s) can take a null as parameter, but compiler decides whih of them most optimal. method(Object o) is most general but method(String s) most concrete and compiler chooses second method with String parameter.
Serghei is quite correct here. But the word "specific" is a better choice than "optimal" or "concrete". That is, the compiler chose String because it is more specific than Object (from which String is derived).
Hi Barry. Thanks for correction. Unfortunately English is not my mother tongue and not my second language.
Joined: Apr 02, 2004
Answers The code does not compile. The code compiles cleanly and shows "StringBuffer Version". The code compiles cleanly and shows "String Version" What would be result now since now both strinbuffer and sting are both specific.
Joined: Jul 24, 2002
Compile-time error because reference to method is ambiguous.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com