Interface freeloading on a superclass - is it good practice?



This appears to be legal:

public interface MyInterface {
void setEnabled(boolean enabled);
}

public class MyComponent extends java.awt.Component
implements MyInterface {
// setEnable() NOT implemented, 'cause it comes with Component
}

It compiles and runs, although it appears to me there is something
conceptually wrong. Shouldn't 'implemeting an interface' mean just
that, not freeloading on some superclass?

And will it always work, on any version of VM?

Some techniques can be technically ok but still considered bad
programming practice. What about this one?


Chris

.



Relevant Pages

  • Re: Interface freeloading on a superclass - is it good practice?
    ... > public interface MyInterface ... > public class MyComponent extends java.awt.Component implements ... > It compiles and runs, although it appears to me there is something ... > Some techniques can be technically ok but still considered bad ...
    (comp.lang.java.programmer)
  • Re: Interface freeloading on a superclass - is it good practice?
    ... public interface MyInterface { ... public class MyComponent extends java.awt.Component implements MyInterface { ... not freeloading on some superclass? ... Some techniques can be technically ok but still considered bad ...
    (comp.lang.java.programmer)