Interview Questions

Output question 17.

Java Interview Questions and Answers (part 4)


(Continued from previous question...)

77. Output question 17.

class MyThread extends Thread {
}
public class MyClass {
public static void main(String[] args) {
Thread thread1=new MyThread();
thread1.start();
}
}



Answer.
Nothing will be printed in output.

When we call start() method on thread, it internally calls run() method with newly created thread. So, if we don’t override run() method newly created thread won’t be called and nothing will happen.

(Continued on next question...)

Other Interview Questions