It is a collection of an only abstract method as well as constant variables or data member.
Characteristics of Interfaces:
1. All Methods of an Interfaces are by default an abstract & public.
2. No need to make or mention abstract before the method.
3. A class implements to an interface not extends. e.g: interface Ravi
class Rabi implements Ravi {
{
void show();
void display();
}
}
4. Interface creates by using interface keywords. e.g:
interface Ravi {
void show();
}
5. An interface cannot implements another interface.
6. An interface can extend another interface. e.g: interface Ravi
interface Rabi extends Ravi {
{
void show();
void display();
}
}
7. We cannot create an object to an interface, but we can create a reference of an interface type.
8. It is possible to write a class within an interface.
9. A class can implement multiple interfaces.
e.g: interface Ravi
interface Rabi { {
void show();
void display();
}
}
Class A { …………… …………… }
Class B extends A implements Rabi , Ravi { …………. ………….. }
So no need of Multiple Inheritance in Java.
10. An interface can have variables which are public static and final by default. This means all the variables of the interface are constants