File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract classes and Interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Abstract classes and Interfaces" Watch "Abstract classes and Interfaces" New topic
Author

Abstract classes and Interfaces

Maduranga Liyanage
Ranch Hand

Joined: May 25, 2005
Posts: 124
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

Joined: May 05, 2005
Posts: 22
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

Joined: May 05, 2005
Posts: 22
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

Joined: May 25, 2005
Posts: 124
So are all methods in Interfaces Abstract?
Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
All methods in an interface are implicitly public, abstract and non-static.
Marcelo Ortega
Ranch Hand

Joined: May 31, 2005
Posts: 519

Yep, all of the methods declared in an interface are implicitly public abstract, and therefor must ALL be implemented in the first concrete class.



SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD, SCEA/OCMJEA

Live life to an interface, not an implementation!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract classes and Interfaces