About Question enthuware.ocpjp.v8.2.1291 :
Posted: Sat Jul 09, 2016 9:20 pm
Hi
Please consider the following code
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.