Sail E0 Webinar

MCQs

Total Questions : 22 | Page 3 of 3 pages
Question 21. Given the code. What will be the result?public class Test implements Runnable{ public static void main(String[] args) throws InterruptedException{ Thread a = new Thread(new Test()); a.start(); System.out.print("Begin"); a.join(); System.out.print("End"); } public void run(){ System.out.print("Run"); }}
  1.    Compilation fails.
  2.    An exception is thrown at runtime.
  3.    "BeginEndRun" is printed.
  4.    "BeginEnd" is printed.
  5.    "BeginRunEnd" is printed.
 Discuss Question
Answer: Option E. -> "BeginRunEnd" is printed.
Question 22. What will be output of the following program code?public class Test implements Runnable{ public void run(){ System.out.print("go"); } public static void main(String arg[]) { Thread t = new Thread(new Test()); t.run(); t.run(); t.start(); }}
  1.    Compilation fails.
  2.    "go" is printed
  3.    "gogo" is printed
  4.    An exception is thrown at runtime.
  5.    "gogogo" is printed
 Discuss Question
Answer: Option E. -> "gogogo" is printed

Latest Videos

Latest Test Papers