Interfaces in Java

Interfaces It is one of the ways to achieve abstraction in Java. It will have only method declaration(abstract methods) and constant attributes in it. It cannot be instantiated like how we can’t instantiate abstract class. They are used to achieve multiple inheritance and polymorphism. Java interface Example public interface Hello{ String str = ”hello”; void […]

Share this article on

Inheritance in Interface

interface A{ void show(); }   interface B extends A{ void print(); } interface A{ void show(); } interface B extends A{ void print(); } Now interface ‘B’ is inheriting interface ‘A’. Now class implementing ‘B’ should implement both show() and print() methods. Ground rule : Class can implement more than one interfaces. Interface can […]

Share this article on
< Previous Next >