aspose file tools*
The moose likes Beginning Java and the fly likes keywords implements and extends 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 » Java » Beginning Java
Bookmark "keywords implements and extends" Watch "keywords implements and extends" New topic
Author

keywords implements and extends

vikas motkur
Greenhorn

Joined: Aug 08, 2007
Posts: 1
How are the key words different both are used to incorporate inheritance..why is there a difference???
David McCombs
Ranch Hand

Joined: Oct 17, 2006
Posts: 212
To put it simply extends is used to inherit other classes both abstract and non-abstract. implements is used in classes to inherit interfaces.


"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."- Stan Kelly-Bootle
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
implements is used in classes to inherit interfaces


You mean you will provide a legal implementation of the interface so that code outside your class can be sure that certain implementation of methods exist.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
David McCombs
Ranch Hand

Joined: Oct 17, 2006
Posts: 212
Originally posted by Remko Strating:


You mean you will provide a legal implementation of the interface so that code outside your class can be sure that certain implementation of methods exist.


Yeah, I didn't like that when I wrote it, but couldn't think of a better answer at the time. Not all interfaces have methods defined, so perhaps a better explanation is when a class needs to use the implied contract of an interface.

And if an interface "inherits" another interface, extends is used.

[ August 08, 2007: Message edited by: David McCombs ]
[ August 08, 2007: Message edited by: David McCombs ]
 
Consider Paul's rocket mass heater.
 
subject: keywords implements and extends