Menu
Question Index
...

What will be the output of the following program?

public class Waiting {
    public static void main(String[] args) {
        System.out.print("1 ");
        synchronized (args) {
            System.out.print("2 ");
            try {
                args.wait(); //LINE M
            }
            catch (InterruptedException e) {    System.out.println("4 ");    }
        }
        System.out.print("3 ");
    }
}


1 2 4 3
1 2 3
1 3
1 2
Program execution does not complete
Compilation Error or Runtime Error

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App