Home > Back-end >  How does a parent class implements subclasses of the interface
How does a parent class implements subclasses of the interface

Time:04-16

Consult everybody Java a great god, and if the Parent class Parent one way public void () {}, a Child has a subclass inherits the Parent class Parent, while implementing an interface IChild, IChild method defines a void within a (), by definition, the Child did not implement the interface method, but because of a name came from the Parent class inherits the same way, so the compiler is not an error, do have any problems, although you can run, but from the Java will there be a problem on the operation principle of mechanism, performance will there be?

Public class Parent {
Public void (a) {
System. The out. Println (" a ");
}
}

Public interface IChild {
Void (a);
}

Public class Child extends the Parent implements IChild {
}

Public class Main {
Public static void main (String [] args) {
The Child c=new Child ();
C.a. ();
}
}
  • Related