Subclass can directly implement an Interface though the Superclass has not implemented it. See the below example to find out how the Subclass can directly implement an Interface:
class ClassTwo extends ClassOne implements Interface1, Interface2
{
//Body of the Subclass
}
Lets implement this on Eclipse IDE:
1. Create an 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', 'Subclass' and 'SubclassInterfaceDemo' class files used in this post (You can download this project and import into Eclipse IDE on your machine)
Please comment below to feedback or ask questions.
Implementing the Interface containing variables will be explained in the next post.
No comments:
Post a Comment