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 is from the mock exam at http://www.geocities.com/SiliconValley/Screen/5046/ftest1.html. The directions say to check all of the following statements which are true: 1. An inner class can have the same name as its enclosing class. 2. An instance of a non-static inner class always has an associated instance of the enclosing class. 3. An anonymous inner class is always assumed to extend Object. According to the results, only answer #2 is correct. But don't ALL objects extend Object? Please advise.
Stephanie Grasson, The given answer is correct. You have to read the question carefully,what it says is An anonymous inner class is always assumed to extend Object. Not necessarily Always, Anonymous class can extend to other class also. That is why the answer is '2'. Hope this may help to some extend. Thanks Nirmala
Joined: Nov 22, 2008
But aren't you still extending Object in that case? It may not be the immediate parent, but it's being extended, nonetheless.
anonymous class can: 1. either implement an interface 2. or extend an abstract class. I think, always assumed means that if anonymous class is not made from an abstract class, it extends Object. The requirement to assume will only arise when U dunno which class it extends to (i.e. interfae). so answers 2,3 should be right.