aspose file tools*
The moose likes Java in General and the fly likes Difference between Abstract class and Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difference between Abstract class and Interface" Watch "Difference between Abstract class and Interface" New topic
Author

Difference between Abstract class and Interface

Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
Hello friends ,
I am back here with some questions on interview which i have with me and i would like the clarification for the same.Please would u lemme know that wats the exact diffrence between an abstract class and an interface ??


Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Angel Dobbs-Sciortino
Ranch Hand

Joined: Sep 10, 2003
Posts: 101
One big difference is an abstract class can implement some of the methods, and an interface cannot.
Angel
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Another key difference is how they are used. If you have an abstract class the assumption is that one or more concrete classes will extend it and supply any missing functionality. If you have an interface the assumption is that there will be one or more classes that will implement it. However these new classes can extend only one parent class, but can implement multiple interfaces.
Often the best design choice is to create an interface and a class (possibly abstract) that provides a default implementation of that interface. Then other designers have the choice of either using the interface or the class, whichever is most appropriate for their needs.
A good example of this is with how the AWT event listeners were implemented. For nearly every java.awt.event.XXXListener (interface) there is a corresponding java.awt.event.XXXAdapter (abstract class). It's a powerful design pattern.
[ November 17, 2003: Message edited by: Wayne L Johnson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Abstract class and Interface