Difference between extends and implements keywords

extends is for extending a class. 

implements is for implementing an interface.

extends is for when you're inheriting from a base class (i.e. extending its functionality). 

implements is for when you're implementing an interface.

A class can only "implement" an interface. A class only "extends" a class. Likewise, an interface can extend another interface. A class can only extend one other class. A class can implement several interfaces.

No comments:

Post a Comment