1.

What Is The Output Of This Program? 1. Class Newthread Implements Runnable { 2. Thread T; 3. Newthread() { 4. T = New Thread(this,"my Thread"); 5. T.start(); 6. } 7. } 8. Class Multithreaded_programing { 9. Public Static Void Main(string Args[]) { 10. New Newthread(); 11. } 12. }

Answer»

Thread t has been made by using Runnable interface, hence it is necessary to use inherited abstract method RUN() method to specify instructions to be implemented on the thread, since no run() method is used it gives a COMPILATION error.

Output:

$ javac multithreaded_programing.java
The TYPE NEWTHREAD must implement the inherited abstract method Runnable.run()

Thread t has been made by using Runnable interface, hence it is necessary to use inherited abstract method run() method to specify instructions to be implemented on the thread, since no run() method is used it gives a compilation error.

Output:

$ javac multithreaded_programing.java
The type newthread must implement the inherited abstract method Runnable.run()



Discussion

No Comment Found

Related InterviewSolutions