What is the output? public class Example { public static voi…
What is the output? public class Example { public static void main(String[] args) throws InterruptedException { Thread t = new Thread(() -> { try { Thread.sleep(2000); System.out.println(“Hello”); } catch (InterruptedException e) { System.out.println(“Interrupted”); } }); t.start(); t.join(); System.out.println(“World”); } }
Read DetailsWhat will be the output of the following code? class MyThre…
What will be the output of the following code? class MyThread extends Thread { public void run() { System.out.print(“A “); } public static void main(String[] args) { MyThread t = new MyThread(); t.run(); System.out.print(“B “); } }
Read DetailsWhat is the output of the following program? public class De…
What is the output of the following program? public class Demo extends Thread { public void run() { try { System.out.println(“Thread started”); Thread.sleep(1000); System.out.println(“Thread resumed”); } catch (InterruptedException e) { System.out.println(“Interrupted”); } } public static void main(String[] args) { Demo t = new Demo(); t.start(); t.interrupt(); } }
Read Details