Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

difference betweem abstract & interface

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can any one say me the exact difference between the abstract
class and the interface
Regards,
Sangeetha Prabindh
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ...
 
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic