MCQ Practice Single Best Answer Topic: Java thread MCQ

Q What will be the output?
class A extends Thread{
      public void run(){
            for(int i=0; i<2; i++){
                  System.out.println(i);
            }
      }
}

public class Test{
      public static void main(String argv[]){
            Test t = new Test();
            t.check(new A(){});
      }
      public void check(A a){
            a.start();
      }
}

Question ID
#2302
Subchapter
Java thread MCQ
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A 0 0
  • B Compilation error, class A has no start method
  • C 0 1
  • D Compilation succeed but runtime exception
Correct Answer: C

Explanation

0 1

Share This Question

Share this MCQ with your friends or study group.