Question 1


What will happen if you compile/run this code? 1: public class Q1 extends Thread 2: { 3: public void run() 4: { 5: System.out.println("Before start method"); 6: this.stop(); 7: System.out.println("After stop method"); 8: } 9: 10: public static void main(String[] args) 11: { 12: Q1 a = new Q1(); 13: a.start(); 14: } 15: } A) Compilation error at line 7. B) Runtime exception at line 7. C) Prints "Before start method" and "After stop method". D) Prints "Before start method" only.
1