No need of implementing an Interface in Subclass if the Superclass has already implemented the interface. If Superclass has already implemented an interface, the subclass can inherit it without implementing the interface again.
Lets implement this on Eclipse IDE:
1. Create Interface 'Interface1' as shown below:
2. Create 'Superclass' class which implements the 'Interface1' as shown below:
3. Create 'Subclass' class (i.e. subclass of 'Superclass' class) which don't implement the 'Interface1' as the 'Interface1' has already implemented it as shown below: (subclass will inherit the implemented Interface1 )
4. Create 'HierarchyInterfaceDemo' class to access the method of Interface1 which is implemented in the Super and Sub classes as shown below:
5. Save and Run the 'HierarchyInterfaceDemo' class
6. Observe that the output is displayed in the console as shown below:
Download this project:
Click here to download the project containing the 'Interface1', 'Superclass' and 'Subclass' files used in this post (You can download this project and import into Eclipse IDE on your machine)
Lets implement this on Eclipse IDE:
1. Create Interface 'Interface1' as shown below:
6. Observe that the output is displayed in the console as shown below:
Click here to download the project containing the 'Interface1', 'Superclass' and 'Subclass' files used in this post (You can download this project and import into Eclipse IDE on your machine)