Examveda
Examveda

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();
      }
}

A. Compilation fails.

B. An exception is thrown at runtime.

C. "go" is printed

D. "gogogo" is printed

E. "gogo" is printed

Answer: Option D


This Question Belongs to Java Program >> Threads

Join The Discussion

Related Questions on Threads

What is a thread in Java?

A. A lightweight process that runs independently within a program

B. A data structure to store variables

C. A type of loop

D. A synchronization mechanism