java Multithreading Mcqs

Our collections of Multiple choice questions and answers focuses on study of java Multithreading. These questions are chosen from a collection of most authoritative and best reference books on Java. Our aim is to prepare an individual for competitive exams like NTS, GAT, ECAT, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate Java Multithreading topic comprehensively.

1.
What is the output of this program?

    class newthread implements Runnable
    {
 Thread t;
 newthread()
        {
     t = new Thread(this,"My Thread");
     t.start();
 }
 public void run()
        {
     System.out.println(t);
 }
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }

My Thread

Thread[My Thread,5,main].

Compilation Error

Runtime Error

4.
What is the output of this program?

    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            t.setName("New Thread");
            System.out.println(t);        
        }
    }

Thread[5,main].

Thread[New Thread,5].

Thread[main,5,main].

Thread[New Thread,5,main].

5.
What is the priority of the thread in output of this program?

    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            t.setName("New Thread");
            System.out.println(t.getName());        
        }
    }

Main

Thread

New Thread

Thread[New Thread,5,main].

8.
What will happen if two thread of the same priority are called to be processed simultaneously?

Anyone will be executed first lexographically

Both of them will be executed simultaneously

None of them will be executed

It is dependent on the operating system

9.
What is the output of this program?

    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }

Thread[5,main].

Thread[main,5].

Thread[main,0].

Thread[main,5,main].

10.
What is the priority of the thread in output of this program?

   class multithreaded_programing 
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }

4

5

0

1

11.
What is the name of the thread in output of this program?

    class multithreaded_programing
    {
        public static void main(String args[])
        {
            Thread t = Thread.currentThread();
            System.out.println(t);        
        }
    }

Main

Thread

System

None of the mentioned

15.
What is true about time slicing?

Time slicing is OS service that allocates CPU time to available runnable thread

Time slicing is the process to divide the available CPU time to available runnable thread

Time slicing depends on its implementation in OS

Time slicing allocates more resources to thread

0Shares
0
Scroll to Top