Menu
Question Index
...

What will be the output of the following program?

public class Bottle
{
    public static void main(String[] args)
    {
            new Bottle().water();
    }

    public void water()
    {
        int i = 5;
        Thread t = new Thread(new Runnable()
        {
            public void run()
            {
                for(int j = 0; j <= i; j++)
                {
                    System.out.print(j + " ");
                }
            }
        });
        t.start();
    }
}


0 1 2 3 4 5
0 1 2 3 4
Compilation Error
Runtime Error

Doubts

Problems

Topic: What is Multitasking and Multithreading?

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App