1. What will be the output of the program? class MyThread extends Thread { public static void main(String [] args) { MyThread t = new MyThread(); Thread x = new Thread(t); x.start(); / Line 7 / } public void run() { for(int i = 0; i < 3; ++i) { System.out.print(i + ".."); } } }
Ask Your Doubts Here
Comments
By: guest on 02 Jun 2017 01.26 am
The thread MyThread will start and loop three times (from 0 to 2). Option A is incorrect because the Thread class implements the Runnable interface; therefore, in line 7, Thread can take an object of type Thread as an argument in the constructor. Option B and C are incorrect because the variable i in the for loop starts with a value of 0 and ends with a value of 2.