• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

exact differance between abstract class and interface

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please can you define the difference between interface and abstract class
------------------
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not really an "advanced" question so I'm moving it to Java In General (intermediate).
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An abstract class can provide the bodies for least some methods. That is, only some of the class methods need be abstract. The remaining can be provided in the base (abstract) class. An interface requires that all methods be specified in the derived class which implements the interface. If I have an abstract class that provides no methods of its own, then I always think about converting it to an interface.
Also, a class which extends an abstract class, cannot extend any other class. A class which implements an interface can extend any class.
If your class has methods that are best implemented in the base class, use an abstract class. If all your methods are best implemented in the derived classes, consider using an interface as it is more flexible.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic