SOME FACTS ABOUT EXTENDS AND IMPLEMENTS

-A class can extend another class and implements another(more than one) interface
-An interface can extend another interface.
-An interface can itself extend another interface, but never implement anything.
-If the implementation class of an interface(abstract class) is abstract, it can simply pass the buck to its first concrete subclass. (No need to override the interface methods in the abstract class).
for classes that claim to implement an interface but don't provide the
correct method implementations. Unless the implementing class is abstract, the
implementing class must provide implementations for all methods defined in the
interface.

You can extend only one class, but implement many interfaces. But remember
that subclassing defines who and what you are, whereas implementing defines a role
you can play or a hat you can wear, despite how different you might be from some
other class implementing the same interface (but from a different inheritance tree).
For example, a Person extends HumanBeing (although for some, that's debatable).
But a Person may also implement Programmer, Snowboarder, Employee, Parent.

COMPARING CONCRETE ABSTRACT EXAMPLE OF EXTENDS AND IMPLEMENTS


LEGAL USE OF EXTENDS AND IMPLEMENTS

No comments:

Post a Comment