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.
Compiler will not generate any error. Infact the program also runs and gives the result of m2. This is because the compiler will map null to the "most specific object" that null can be cast into which is String. The rule is String is-a Object but Object is-not-a String . so the null is cast into a string. I remember reading it somewhere in JLS via one of Dan's mock exams. Search the post and you will find the solution in one of the posts Thanks Sri [ February 15, 2003: Message edited by: Sri Sri ]
Joined: Feb 15, 2003
it compiles and runs fine just like Sri Sri said, but I want to know why. Thanks Sri sri