Programming Language Java thread MCQ Question #2306
Single Choice Not Set

QWhat will be the output after compiling and executing the following code?
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");
      }
}

ID: #2306 Java thread MCQ 926 views
Question Info
#2306Q ID
Not SetDifficulty
Java thread MCQTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Compilation fails.
  • B An exception is thrown at runtime.
  • C "BeginRunEnd" is printed.
  • D "BeginEndRun" is printed.
Correct Answer

Explanation

"BeginRunEnd" is printed.

Share This Question

Challenge a friend or share with your study group.