Java OOP – Java Interfaces
August 22, 2020 1 min read

An interface is a reference type in Java. It is similar to class. It is a collection of abstract methods. Sub class of an interface cannot be extended. It should be implemented.
- You can visit the article Abstraction to get knowledge about abstract classes and methods.
To access the method inside the sub class, we should use modifiers. Those modifiers should have more visibility than the modifiers used inside the super class.
Only characteristics are implemented to the sub class by the super class.
Let’s see some of the cases we should consider when we use java interfaces.
Case I
We cannot make a sub class by extending an interface.

Case II
We cannot code anything inside the body of an interface as it converts to an abstract class automatically.

Case III
Methods inside an interface becomes public automatically. We cannot use protected modifier to those methods.

Case IV
We can make reference from an interface name, but cannot make objects.

Case V
We can make objects by an implemented class (sub class).

Case VI
We can use polymorphism for interfaces.

Case VII
Sub classes of the class hierarchy cannot be extended. They should be implemented to inherit the characteristics.

Case VIII
All the sub classes should be implemented and all the methods should be overridden.

Case IX
Interface can be extended by another Interface.

Case X
We cannot make an interface by extending a class.

Case XI
To access an attribute inside an interface, we should use static, final & public key words.

Case XII
We cannot use static, final and private key words for methods as they should be overridden to the sub classes.

If anything wrong or you have any doubt, let me know by put a comment below. Let’s meet with the next article on the topic Inner classes.
Thank you.


