What is the name of the thread in the following Java Program? [code] class multithreaded_programing { public static void

What is the name of the thread in the following Java Program?
Code:
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }
A. main
B. Thread
C. System
D. None of the mentioned
 
Answer: a
Explanation: The output of program is Thread[main,5,main], Since we have not explicitly named the thread they are named by the group to they belong i:e main method. Hence they are named ‘main’.
Output:
Code:
$ javac multithreaded_programing.java
$ java multithreaded_programing
Thread[main,5,main]
This section of our 1000+ Java MCQs focuses on networking basics of Java Programming Language.
 

Tìm kiếm

Back
Top