adplus-dvertising

Welcome to the Multithreading MCQs Page

Dive deep into the fascinating world of Multithreading with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Multithreading, a crucial aspect of Java Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Multithreading, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Java Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Multithreading. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Java Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Multithreading. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Multithreading MCQs | Page 4 of 10

Q31.
Which of the following will ensure the thread will be in running state?
Discuss
Answer: (c).wait()
Q32.
Which of this method is used to avoid polling in Java?
Discuss
Answer: (d).all of the mentioned
Q33.
Which of these method is used to tell the calling thread to give up a monitor and go to sleep until some other thread enters the same monitor?
Discuss
Answer: (a).wait()
Q34.
Which of these method wakes up the first thread that called wait()?
Discuss
Answer: (b).notify()
Q35.
Which of these method wakes up all the threads?
Discuss
Answer: (d).notifyAll()
Q36.
What is the output of this program?
    class newthread extends Thread
    {
 Thread t;
 String name;
 newthread(String threadname)
        {
     name = threadname;
     t = new Thread(this,name);
     t.start();
 }
 public void run()
        {
        }
 
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
     newthread obj1 =   new newthread("one");
     newthread obj2 =  new newthread("two");
            try
            {
                obj1.t.wait(); 
                System.out.print(obj1.t.isAlive());
            }
            catch(Exception e)
            {
     System.out.print("Main thread interrupted");
            }
        }
    }
Discuss
Answer: (c).Main thread interrupted
Q37.
What is the output of this program?
    class newthread extends Thread
    {
 Thread t;
 String name;
 newthread(String threadname)
        {
     name = threadname;
     t = new Thread(this,name);
     t.start();
 }
 public void run()
        {
        }
 
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
     newthread obj1 =   new newthread("one");
     newthread obj2 =  new newthread("two");
            try
            {
                Thread.sleep(1000); 
                System.out.print(obj1.t.isAlive());
            }
            catch(InterruptedException e)
            {
     System.out.print("Main thread interrupted");
            }
        }
    }
Discuss
Answer: (b).false
Q38.
What is the output of this program?
    class newthread extends Thread
    {
	Thread t;
	newthread()
        {
	    t = new Thread(this,"New Thread");
	    t.start();
	}
	public void run()
        {
	   System.out.println(t.isAlive());
	}
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }
Discuss
Answer: (c).true
Q39.
What is the output of this program?
    class newthread extends Thread
    {
	Thread t1,t2;
	newthread()
        {
	    t1 = new Thread(this,"Thread_1");
	    t2 = new Thread(this,"Thread_2");
	    t1.start();
	    t2.start();
	}
	public void run()
        {
	    t2.setPriority(Thread.MAX_PRIORITY);	
	    System.out.print(t1.equals(t2));
        }    
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }
Discuss
Answer: (d).falsefalse
Q40.
What is the output of this program?
    class newthread implements Runnable
    {
	Thread t;
	newthread()
        {
	    t = new Thread(this,"My Thread");
	    t.start();
	}
    }
    class multithreaded_programing
    {
        public static void main(String args[])
        {
            new newthread();        
        }
    }
Discuss
Answer: (c).Compilation Error
Page 4 of 10

Suggested Topics

Are you eager to expand your knowledge beyond Java Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!