Menu
Topics Index
...
`

Thread1372


If you need explanation Read this topic

If you need Answer Take test on this topic

Thread1372
What will be the output of the following program?
class MyThread extends Thread {
    public static void main(String[] args) {
        MyThread t = new MyThread();
        t.run();
    }
    public void run() {
        for (int i = 1; i < 7; ++i) {
            System.out.print(i + "..");
        }
    }
}

A. 1..2..3..4..5..6..7..
B. 1..2..3..4..5..6..
C. 2..3..4..5..6..7..
D. 2..3..4..5..6..
E. Compilation Error or Runtime Error
Topic: What is Multitasking and Multithreading?

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Answer is B ... we have pre increment operator ++i so  6 numberswhen i becomes 7 condition fails and it prints only

Posted by Jayachandra Gupta    2013-06-13 03:50:14


ans is b...as for loop prints 1 to 6 numbers

Posted by Sulekha Metta    2013-06-13 03:53:26


B.The loop will execute for 6 times.therefore i gets printed till 6.

Posted by Amulya Chappa    2013-06-13 03:53:48


Congratulations Jayachandra Gupta. You are this dose winner. Please send us your mobile details and we will process the recharge asap.

Posted by Merit Campus    2013-06-13 08:35:17


Hey ThanQ Merit Campus but I request you to consider the next possible potential answer from candidate as am trying to test my java basics...Thanks again...!!!

Posted by Jayachandra Gupta    2013-06-14 04:32:11


© meritcampus 2019

All Rights Reserved.

Open In App