3

Today i found in my codes what appears to be a child class implementing an interface that the parent class is already inheriting.

May i know if this has any adverse side effects or intentions, as i am working on to remove it from the child class as i believe this could have been an accidental mistake, or perhaps am i missing something?

In the child class:

public class ProductServiceBean
  extends GenericSessionBean
  implements javax.ejb.SessionBean

In the parent class:

// Compiled from GenericSessionBean.java (version 1.2 : 46.0, super bit)
public abstract class weblogic.ejb.GenericSessionBean 
  extends weblogic.ejb.GenericEnterpriseBean 
  implements javax.ejb.SessionBean

Note that in both child and parent, the classes do implement the javax.ejb.SessionBean.

Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215
  • 1
    Also answered here: http://stackoverflow.com/questions/5668429/why-would-both-a-parent-and-child-class-implement-the-same-interface. – Basel Shishani Aug 20 '14 at 20:26

2 Answers2

4

Removing implements javax.ejb.SessionBean from only the ProductServiceBean class will have no effect, since the fact that the class implements the interface is inherited from the parent GenericSessionBean class.

There is also no harm in including it in the child class, it's just a redundant declaration.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
4

Having both the child and the parent implement the same Interface has no additional effect. It is equivalent to having the parent only implement that interface.

Moe Matar
  • 2,026
  • 13
  • 7