开发者

Parent and child classes implementing a common interface, repeatedly

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 cla开发者_如何学运维sses do implement the javax.ejb.SessionBean.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜