Given a sample code:
1 public class Test implements Runnable {
2 public void run() {
3 System.out.println("Inside run");
4 }
5 public static void main(String[] args) {
6 // place code here.
7 // place code here.
8 t.start();
9 System.out.println("End of main");
}}
What statement should be placed at line number 6 and 7 so that result will
come as
"Inside run"
"End of main"
Choose the correct option:
(A) Runnable r = new Runnable(); and Thread t = new Thread(r);
(B) Runnable r = new Thread(); and Thread t = new Thread(r);
(C) Runnable r = new Test(); and Thread t = new Thread(r);
(D) Runnable r = new Test(); and Thread t = new Thread(new Test);
(C)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.