abstract type method_name(parameter/no parameter) |
Note : Remember that abstract class cannot be instantiated , i.e. we can’t create an object of an abstract class , but can only create a reference variable to refer to other class object which is helpful in run-time polymorphism. |
interface <interface_name> { // fields that are public, static and final by default ; //methods that are public and abstract by default ; } |
class <class_name> implements <interface_name>{ // implement all the methods of interface ; // class fields ; // class methods; } |
Note-1 : A class can implement any number of interfaces , different interfaces name are separated by comma(,) Syntax class <class_name> implements <interface 1>,<interface 2>,….. |
Note-2 : A class can extend another class and implement an interface at the same time. Syntax class <class_name> extends <par_class_name> implements <interface_name> or class <class_name> implements <interface_name> extends <par_class_name> |
Note-3 : An interface can extend another interface. |