1.

What will be the output of the program?

class MyThread extends Thread { MyThread() {} MyThread(Runnable r) {super(r); } public void run() { System.out.print("Inside Thread "); } } class MyRunnable implements Runnable { public void run() { System.out.print(" Inside Runnable"); } } class Test { public static void main(String[] args) { new MyThread().start(); new MyThread(new MyRunnable()).start(); } }

A. Prints "Inside Thread Inside Thread"
B. Prints "Inside Thread Inside Runnable"
C. Does not compile
D. Throws exception at runtime
Answer» B. Prints "Inside Thread Inside Runnable"


Discussion

No Comment Found

Related MCQs