What is Interface ?
- Interface is medium between two different system, when in implementation in the other system and we use interface to access the implementation
- Interface can’t have concrete method that it is inside the interface all abstract
- When a class inherit an interface by using keyword implement that class child mediatory override all the method implement which define in interface if not than child class is abstract class
- We can’t create object of interface rather an interface can refers any object of child object in the entire inheritance hierarchy.
- The method inside an interface is implicitly public.
- The methods an interface all are only public.
- The variable inside the interface are implicitly public, static, and final.
- Interface can also be treated or consider as rules repository.
- Interface can use generally when we deal with third party.
- Interface can’t have constructor. There is no need of initialization of state or behavior.
- Interface can inheritance number of inheritance by using the extend.
- A class can inherit one class (parent) and any N number of interfaces at a same time.
Advantage
- Multiple inheritances possible.
- Loose coupling.
- Zero dependencies.
- Can achieve abstraction.
- Standardize way of accessing the implementation.
- Interface can never be the child of any class (not even object class).
Difference between Abstract Class /
Interface:-
Think:-“Find out Inbuilt
Interface name which are present in java Api??”