| 9.4 | What will be the result of attempting to compile and run the following program? public class MyClass extends Thread { public MyClass(String s) { msg = s; } String msg; public void run() { System.out.println(msg); } public static void main(String[] args) { new MyClass("Hello"); new MyClass("World"); } } Select the one correct answer. -
The program will fail to compile. -
The program will compile without errors and will print Hello and World , in that order, every time the program is run. -
The program will compile without errors and will print a never-ending stream of Hello and World . -
The program will compile without errors and will print Hello and World when run, but the order is unpredictable. -
The program will compile without errors and will simply terminate without any output when run. |