What is the output of the following code?
1. public class Main implements Runnable { 2. public void run() { 3. System.out.println("abc"); 4. start(); 5. } 6. public static void main(String... args) { 7. new Thread(new Main()).start(); 8. } 9. }
c
Class Main implements the Runnable interface; it doesn't extend class Thread.
So it doesn't have access to method start()
.
Calling start()
at line 4 results in the compilation failure.