This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
It's simple, actually. First, when you inherit from a superclass, you automatically inherit all of its methods (except in the case of an abstract class) and have all of the default implementation. For example, when extend Applet, you get methods like add() and repaint() which are immediately usable by you with no coding. When you impliment an interface, you are saying basically 'I promise to implement all of the necessary methods in order for anyone to use this class as a <INTERFACE>. For example, when you implement Runnable, you must write a method called run() with the signature public void run(), because you are saying that the class (or object) is Runnable, so anyone using it can use the run() method. Its designed so that everyone is always on the same page, every Runnable object has a run() method, every ActionListener has an actionPerformed(ActionEvent) method, etc. Helps clear up confusion. Jason
hi, whenever you inherit from a class you get all the methods of superclass automatically inherited. you can apply your own implementation if you wish (but it is'nt necessary) if you inherit from an interface you are bound to implement all the methods contained in the interface, [ February 20, 2004: Message edited by: Lalit K Kumar ]