-
Predict the output of the given code:
{geshibot language="java"}public class Test { private static String msg = "HCL "; static{ Thread t = new Thread(new Runnable(){ public void run(){ msg = "Technologies "; } }); t.start(); } public static void main(String[] args){ System.out.print(msg); }}{/geshibot} a) Compiles and prints HCL b) Compiles and prints Technologies c) Compiles and prints HCL Technologies d) Output can be HCL or Technologies
-
What will be the result of compiling and executing the code listed below?
{geshibot language="java"} public class Finder { public static void main(String[] args){ System.out.println(X.Y.Z); }} class X{ static class Y{ static String Z ="Apple"; } static W Y = new W(); } class W{ String Z = "Orange";}{/geshibot} a) Apple b) Orange c) Compile time Error d) Runtime Exception is thrown