File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abstract classes and Interfaces

 
Maduranga Liyanage
Ranch Hand
Posts: 124
  • 0
  • 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.. :-)
 
Terry Rickson
Greenhorn
Posts: 22
  • 0
  • 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
  • 0
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So are all methods in Interfaces Abstract?
 
Kedar Dravid
Ranch Hand
Posts: 333
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All methods in an interface are implicitly public, abstract and non-static.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Eclipse IDE Hibernate Java
  • 0
  • 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.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic