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.
Just now I started to learn object reference conversion and casting.Looks like I got it when I work out in paper.But I need to work it in computer.Its showing the error I need to make the ApBase and ApDerived classes as abstract.but the question given is like
class ApBase extends Objects implementsRunnable class ApDerived extends ApBase implements Observer //Following variables created from above classes ApBase aBase = new ApBase(); ApDerived aDer = new ApDerived(); which of the following compile and run w/o error ? A) Object obj = aBase; Runnable rn obj; B) Object obj = aBase; Runnable rn = (Runnable)obj; ..........Answer C) Object obj = aBase; Observer ob = (Observer)aBase; D) Object obj = aDer; Observer ob2 = obj;
why do I need to make those classes abstract.If I make it abstract then abstract classes won�t instantiate like this
ApBase aBase = new ApBase(); ApDerived aDer = new ApDerived();
You're getting that error because the class definitions say they are going to implement the Runnable interface and the Observer interface, but there is no definition for the method in those interfaces.
An implements clause is a contract. The class definition is allowed to be treated as an instance of the interface, but it must give concrete implementations to all of the methods listed in the interface. [ October 11, 2006: Message edited by: Keith Lynn ]
Joined: Jan 05, 2006
Keith thank you very much.After i got implement run() method to ApBase class that error is gone .Thanks