class Qus3 extends Thread implements Runnable {
public static void main(String args[]) {
Qus3 q3 = new Qus3();
q3.start();
}
}
This code compiles without any error but isn’t it necessary to define all the methods
of an interface otherwise declare the class abstract.In the above code Class hasn’t been declared abstract and run() is also not defined by the class although it has implemented Runnable interface, why the code is still correct?
Class implements Runnable but also extends Thread. Internally Thread also implements Runnable and provides implementation for it. That is the reason it compiles successfully.
If you remove
extends Thread, you will see it will give compilation error.