• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Abstract classes and Interfaces

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I get some answers please??

1) If an abstract class has more than one abstract method, when a subclass extends that class, does the sub class has to implement all the abstract methods? Can I extend an abstract class and not implement any abstract method?

2) If I implement an interface in my class, can I override a method in the interface? If I can, is there anyway I can get the original method implementation in my overriding class. Like the use of "super" in class methods to refer to the super class method?

Thanks.. :-)
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can help you out on the first question and that is you have to implement all the abstract methods from the abstract class if you are in the first concrete class otherwise if you have an abstract class extending another abstract class then the first concret class must implement all the abstract methods.
 
Terry Rickson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the second question - if you implement an interface you must override the methods in the interface anyway.

Hope i've helped you in some way!
 
Maduranga Liyanage
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So are all methods in Interfaces Abstract?
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All methods in an interface are implicitly public, abstract and non-static.
 
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, all of the methods declared in an interface are implicitly public abstract, and therefor must ALL be implemented in the first concrete class.

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!