• 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

abstract and interface

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
must we implement all abstract methods in a subclass ?
whats the difference btn the above ?
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a class does not implement all the abstract methods it inherits must be declared astract itself.
Both interface an abastract class declare a contract (set of methods) that other classes (subclasses or implementing classes) must obbey. They define a base type to use the "magic" of polymorphism.
Use an interface as the base type whenever a default implementation is not needed for subclasses: Abstract classes may have non-anstract methods that are inherited by subclasses, however you can only inherit from one class; whereas it is possible to implement several interfaces.
You migth find interesting the reading of The Java Tutorial.
[ May 25, 2003: Message edited by: Jose Botella ]
reply
    Bookmark Topic Watch Topic
  • New Topic