Please consider the following code
Output is different opposed to declarationclass A extends Thread{
public A(){}
public A(Runnable r){
}
public void run(){
System.out.println("Thread");}
}
public class Tge implements Runnable {
@Override
public void run() {
System.out.println("Runnable");
}
public static void main(String[] args) {
new A(new Tge()).start();
}
}
If a Thread is created with a Runnable, Thread class's run() method calls the run() method of the given Runnable.