aspose file tools
The moose likes Java in General and the fly likes Can an abstract class implement an interface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Can an abstract class implement an interface" Watch "Can an abstract class implement an interface" New topic
Author

Can an abstract class implement an interface

Gaurav Chikara
Ranch Hand

Joined: Jun 09, 2000
Posts: 410
Hi
I could have tried it instead of asking on forum but due to some sw problem I could not do
Can any one pls tell me whether it is legitimate or not?
abstract class says it implemnets an interface but instaed of impleneting the methods it declares them as abstract
Is it legal?


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Yes. Any concrete subclass will have to implement the abstract methods, so they will be implemented by the time any JVM is asked to invoke the method. It's just a special case of implementing by forcing subclasses to implement for you.


"I'm not back." - Bill Harding, Twister
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Originally posted by Gaurav Chikara:
abstract class says it implemnets an interface but instaed of impleneting the methods it declares them as abstract
Is it legal?

As Jim already explained; yes this is perfectly legal. Even more, your abstract class doesn't even have to mention the methods in the interface it 'implements' (mind the quotes), e.g. the following:

is perfectly legal. If a subclass of YourClass wants to be concrete class, it has to implement both foo() and bar().
kind regards
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: Can an abstract class implement an interface
 
Similar Threads
abstract vs interface
Diff bw Abstract class and Interface
interface
when to use abstract ?
abstract class