MCQ Single Best Answer Not Set

QPredict the output:
class A implements Runnable{
      public void run(){
            try{
                  for(int i=0;i<4;i++){
                        Thread.sleep(100);
                        System.out.println(Thread.currentThread().getName());
                  }
            }catch(InterruptedException e){
            }
      }
}

public class Test{
      public static void main(String argv[]) throws Exception{
            A a = new A();
            Thread t = new Thread(a, "A");
            Thread t1 = new Thread(a, "B");
            t.start();
            t.join();
            t1.start();
      }
}

ID: #2301 Java thread MCQ 980 views
Question Info
#2301Q ID
Not SetDifficulty
Java thread MCQTopic

Choose the Best Option

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

  • A A A A A B B B B
  • B A B A B A B A B
  • C Output order is not guaranteed
  • D Compilation succeed but Runtime Exception
Correct Answer: Option A

Explanation

A A A A B B B B

Share This Question

Challenge a friend or share with your study group.