Examveda
Examveda

Given the code. What will be the result?
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");
      }
}

A. Compilation fails.

B. An exception is thrown at runtime.

C. "BeginRunEnd" is printed.

D. "BeginEndRun" is printed.

E. "BeginEnd" is printed.

Answer: Option C


This Question Belongs to Java Program >> Threads

Join The Discussion

Comments ( 1 )

  1. Tamene Adisu
    Tamene Adisu :
    6 years ago

    not intersting

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