This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes difference betweem abstract & interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "difference betweem abstract & interface" Watch "difference betweem abstract & interface" New topic
Author

difference betweem abstract & interface

Vasantha Prabha
Ranch Hand

Joined: Oct 02, 2003
Posts: 108
can any one say me the exact difference between the abstract
class and the interface
Regards,
Sangeetha Prabindh


Regards,Vasantha<p>Great minds discuss ideas. Average minds discuss events. Small minds discuss people.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
This topic has been discussed many-a-times in the Saloon. Try a quick search on this forum, the intermediate forum, and the OO, Patterns and UML forum.
Note that the search page link is at the top right of this page.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Jacquie Barker
author
Ranch Hand

Joined: Dec 20, 2000
Posts: 201
All classes are abstractions of real world things (abstraction = deciding what details are essential for modeling something).
Abstract classes are a bit more abstract than "normal" classes because they (typically*) contain one or more abstract methods: that is, methods without bodies whose signatures specify (a) what services an object derived from that class must be able to perform, and (b) how to request such services (the method signature), but (c) without specifying HOW the object needs to do it. However, most abstract classes still have "concrete" data structures/attributes, which the implementing subclasses inherit. Hence, abstract classes in theory mandate, to a certain extent, what data should be used in carrying out the "mission" of an object, even if some of the behavioral details are open-ended.
Interfaces are even more abstract than abstract classes, in that they consist ONLY of abstract method signatures (and potentially constant data values) -- no data structure in the form of attributes. That is, an interface describes a series of behaviors that an object implementing the interface must be able to perform WITHOUT prescribing the data structure that the implementing object must use to carry out those behaviors.
* It is possible to declare a class to be abstract even if it doesn't contain abstract methods ...


Author of Beginning Java Objects, Beginning C# Objects, and Taming the Technology Tidal Wave
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: difference betweem abstract & interface
 
Similar Threads
abstract class Vs interface
Interface
what are the most common questions on Java job interviews?
difference between abstract class and an interface
i want answer