implements interface in java | Java Course Online

This Java Course Online “implements interface in java” is providing clearly about how to implements an interface in java application and why we need to implements interface instead of extends in Java.


 

Why interface need to be implemented?

  • Any class can “implements” interface.
  • We cannot use “extends” keyword while using interface.
  • Interface methods are public by default.
  • We need to override specification of interface methods as public.

 

Why a class ‘implements’ interface instead of ‘extends’ ?

  • Class or Abstract class having definitions.
  • We can update the method which is defined either in Class or Abstract class.
  • We use extends(update) in case of Class and Abstract class.
  • In case of ‘interface’ only specifications will be present.
  • We need to implement these specifications.

Implements Interface in Java

 

Note: If any class is unable to ‘implements’ all the specifications of interface become ‘abstract class’.

 

Share this