1.

What will happen if we don’t override the thread class run() method?

Answer»

Nothing will happen as such if we don’t OVERRIDE the run() method. The compiler will not show any error. It will EXECUTE the run() method of thread CLASS and we will just don’t get any output because the run() method is with an EMPTY implementation. 

Example:  

class MyThread extends Thread { //don't override run() method } public class DontOverrideRun { public static void main(String[] args) { System.out.println("STARTED Main."); MyThread thread1=new MyThread(); thread1.start(); System.out.println("Ended Main."); } }

Output: 

Started Main. Ended Main.


Discussion

No Comment Found