JAVA Programming :: Threads - Discussion
Home > JAVA Programming > Threads > MCQs Questions Discussion
2 / 6
What is the output for the below code ?
class A implements Runnable{
public void run(){
System.out.println("run-a");
}
}
public class Test {
public static void main(String... args) {
A a = new A();
Thread t = new Thread(;
t.start();
t.start();
}
}
class A implements Runnable{
public void run(){
System.out.println("run-a");
}
}
public class Test {
public static void main(String... args) {
A a = new A();
Thread t = new Thread(;
t.start();
t.start();
}
}
Arun-a
Brun-a run-a
CCompilation fails with an error at line 6
DCompilation succeed but Runtime Exception
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
We cannot restart a thread once it has already started, until and unless it executes itself completely. If we do so, we will get a RuntimeException saying IllegalThreadStateException.
Read Full Answer
Report Error
Please Login First Click Here