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

QWhat will be the output of the following program code?
public class Test implements Runnable{
        public static void main(String[] args){
                Thread t = new Thread(this);
                t.start();
        }

        public void run(){
                System.out.println("test");
        }
}

ID: #2294 Java thread MCQ 1,898 views
Question Info
#2294Q ID
Not SetDifficulty
Java thread MCQTopic

Choose the Best Option

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

  • A The program does not compile because this cannot be referenced in a static method.
  • B The program compiles fine, but it does not print anything because t does not invoke the run() method
  • C The program compiles and runs fine and displays test on the console.
  • D None of the above
Correct Answer

Explanation

The program does not compile because this cannot be referenced in a static method.

Share This Question

Challenge a friend or share with your study group.