• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interface implementation in a subclass  RSS feed

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hola,
Class a is a superclass of class b. Class a also implements interface Implementable. Is subclass b required to provide implementation of Implementable although b itself did not explicitly declared that it implements Implementable?
[code]
public class a implements Implementable {
...//some code here for implementation of Implementable's methods
}

class b extends a {
//does b have to provide implementation of Implementable?
}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's a small demo program which should demonstrate the answer

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

if all the methods in the interface are defined in the super class A, then it is not required to redefine those methods in the sub class B.

BUT

if all the methods are not defined in the super class A then the super class A must be made Abstract and the sub class B must define those methods that are not defined in the super class A.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!