Site icon DataFlair

Quiz on Multithreading in Java

quiz on multithreading in java

Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java

Unleash the power of parallel processing with multithreading! This quiz delves into the intricacies of multithreading in Java, a fundamental concept for building responsive and efficient applications.

By testing your knowledge on key aspects like thread independence, shared memory, and concurrency, this quiz will help you identify areas for improvement and solidify your understanding of multithreading.

Whether you’re a seasoned Java developer or just starting to explore multithreading, this quiz is an excellent tool to gauge your grasp of this critical programming technique.

Time limit: 0

Quiz Summary

0 of 15 Questions completed

Questions:

Information

You have already completed the quiz before. Hence you can not start it again.

Quiz is loading…

You must sign in or sign up to start the quiz.

You must first complete the following:

Results

Quiz complete. Results are being recorded.

Results

0 of 15 Questions answered correctly

Your time:

Time has elapsed

You have reached 0 of 0 point(s), (0)

Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)

Categories

  1. Not categorized 0%
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  1. Current
  2. Review / Skip
  3. Answered
  4. Correct
  5. Incorrect
  1. Question 1 of 15
    1. Question

    Which of the following is not an advantage of MultiThreading in Java ?

    Correct
    Incorrect
  2. Question 2 of 15
    2. Question

    class Threading extends thread {

    public void run {

    try() {

    System.out.println(Thread.currentThread.getId());

    }

    }

    catch(Exception e )

    {

    System.out.println(e);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    int number =3;

    for(i=0;i<number;i++);

        Thread t = new Thread( new Threading);

        t.start();

    }

    }

    How many times does the thread class is invoked?

    Correct
    Incorrect
  3. Question 3 of 15
    3. Question

    Which of the following is the correct syntax to set the priority of a thread ?

    Correct
    Incorrect
  4. Question 4 of 15
    4. Question

    Which of the following is true about threads in Java ?

    Correct
    Incorrect
  5. Question 5 of 15
    5. Question

    class ThreadDemo extends Thread {

    public void run ( ) 

    {

    System.out.println(“Thread Class is extended “);

    }

    public static void main ( String args [ ] )

    {

    ThreadDemo thread = new ThreadDemo();

    thread.setPriority(Min_Priority);

    }

    }

    What will be the output of the program ?

    Correct
    Incorrect
  6. Question 6 of 15
    6. Question

    Which of the following is the correct syntax for returning the state of a current thread ?

    Correct
    Incorrect
  7. Question 7 of 15
    7. Question

    Which of the following methods is used to set the priority of a thread ?

    Correct
    Incorrect
  8. Question 8 of 15
    8. Question

    class ThreadSuspend extends Thread {

    public void run ( )

    {

    for( int i = 0 ; i < 5 ; i ++ )

    {

    System.out.println(“DataFlair”);

    if ( i == 3 ) {

    thread.suspend();

    }

    }

    public static void main ( String args [ ] )

    {

    ThreadSuspend thread = new ThreadSuspend();

    thread.start();

    }

    }

    How many times will the String DataFlair be printed in the given program ?

    Correct
    Incorrect
  9. Question 9 of 15
    9. Question

    class MultipleThreads extends thread {

    public void run ( ) {

    System.out.println(“Thread One”);

    }

    }

    class MultiThreads extends thread {

    public void run ( )

    {

    System.out.println(“Thread two”);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    MultipleThreads thread1 = new MultipleThreads();

    thread1.setPriority(Min_Priority);

    thread1.start();

     

    MultiThreads thread2  = new MultiThreads();

    thread2.setPriority(Avg_Priority);

    thread2.start();

    }

    }

    Which of the given threads will be executed first ?

    Correct
    Incorrect
  10. Question 10 of 15
    10. Question

    What is the function of a getPriority() method in a thread class ?

    Correct
    Incorrect
  11. Question 11 of 15
    11. Question

    class SetName extends Thread {

    public void run ( )

    {

    System.out.println( thread.getname());

    }

    public static void main ( String args [ ] )

    {

    SetName thread = new SetName ();

    thread.start();

    }

    }

    What is the error in the program ?

    Correct
    Incorrect
  12. Question 12 of 15
    12. Question

     class Sample extends Thread {

    public void run ( ) 

    {

    for ( i = 1 ; i < 4 ; i ++ )

    {

    System.out.println(“thread is still running “);

    if( i == 2 )

    {

    thread.suspend();

    }

    if ( thread,isDaemon() == true )

    {

    thread.resume();

    }

    }

    public static void main ( String args [ ] )

    {

    Sample s = new Sample();

    s.start();

    }

    }

    What will be the flow of the given program ?

    Correct
    Incorrect
  13. Question 13 of 15
    13. Question

    Which of the following methods are used to check if a given thread is still working or not ?

    Correct
    Incorrect
  14. Question 14 of 15
    14. Question

     class ThreadClass extends Thread {

    public void run ( )

    {

    System.out.println(“Thread);

    }

    public static void main ( String args [ ] )

    {

    ThreadClass thread = new ThreadClass ();

    boolean answer = thread.isDaemon();

    }

    }

    What is the value of the variable answer in the given program ?

    Correct
    Incorrect
  15. Question 15 of 15
    15. Question

    class MultiThread {

    public void run ( ) 

    {

    System.out.println(“Thread is running”);

    }

    }

    class Main {

    public static void main ( String args [ ] )

    {

    MultiThread thread = new Multithread();

    thread.setName(“DataFlair”);

    thread.setPriority(Max_Priority);

    thread.start();

    }

    }

    What is the name of the created thread in the given program ?

    Correct
    Incorrect

Ready to put your multithreading knowledge to the test? This Java quiz has challenged you with various questions that assess your understanding of thread independence, shared memory, concurrency, and other core multithreading concepts.

By attempting the quiz, you’ve gained valuable insights into your strengths and weaknesses when it comes to multithreading in Java. Remember, effective learning is a continuous process. Explore additional resources beyond the quiz to deepen your knowledge and become a multithreading master!

Exit mobile version