What will be the result of compilation and execution of the following code?

public class Test extends Thread {

    public static void delay(long t) {
        try {
            Thread.sleep(t);
        } catch (InterruptedException e) {
            System.out.print("Ex-A ");
        }
    }

    public void run() {
        delay(1000);
        halt();
    }

    public void halt() {
        try {
            this.wait();
        } catch (Exception e) {
            System.out.print("Ex-B ");
        }
    }

    public static void main(String args[]) throws Exception {
        Test test = new Test();
        Thread t = new Thread(test);
        t.start();
        delay(100);
        test.interrupt();
        delay(2000);
        t.notifyAll();
    }
}

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes