If a class includes an interface but does not fully implement the methods defined by the interface, then the class must be declared as abstract.
Lets implement this on Eclipse IDE (Interface defines four methods but the abstract class implementing the interface only implements one out of four methods without any errors)
1.Create Interface 'Interface1' which defines four methods as shown below:
4. The following error message asking to implement all the unimplemented methods in Super Class of this Sub Class is displayed -
5. Implement all the methods in the SubClass that are not implemented in the SuperClass as shown below and observe that the error got resolved -
6. Create class 'PartialImplementationDemo' to create an object for 'Subclass' to access the methods inherited and implemented by the Subclass from abstract Superclass as shown below:
8. Observe that the output is displayed in the console as shown below:
Please comment below to feedback or ask questions.
No comments:
Post a Comment