You are on page 1of 5

Threads, Concurrency Patterns / Java Threads / Post Quiz

Started on
Friday, 20 March 2020, 12:20 PM

State
Finished

Completed on
Friday, 20 March 2020, 12:21 PM

Time taken
40 secs

Marks
4.00/4.00

Grade
100.00 out of 100.00

Feedback Congratulations!! You have passed by securing more than 80% 


Question 1

Correct

Mark 1.00 out of


1.00

new Thread(new MyRunnable()).start();   new MyRunnable().start();  


new Runnable(MyRunnable).start();   new Thread(MyRunnable).run();  

public class MyRunnable implements Runnable

{    public void run()

    {

     new Thread(new MyRunnable()).start(); 

    }

Which of these will create and start this thread?



Question 2

Correct

Mark 1.00 out of


1.00

Which of the following methods are defined in class Thread?

Select one or more:

 a. run()

b. notify()

c. wait()

 d. start()

e. terminate()


Your answer is correct.

The correct answers are: run(), start()


Question 3

Correct

Mark 1.00 out of


1.00

class Cthread extends Thread{

   Cthread(){

start();

  public void run(){

  System.out.print("Hi");

public static void main (String args[]){

Cthread th1=new Cthread();

Cthread th2=new Cthread();



}

Predict the output.

Select one:

a. will display Hi once

b. will not create any child thread

c. will create two child threads and display Hi twice


d. compilation error

Your answer is correct.

The correct answer is: will create two child threads and display Hi twice
Question 4

Correct

Mark 1.00 out of


1.00

Which keyword when applied on a method indicates that only one


thread should execute the method at a time?

Select one:

a. lock

b. Synchronized

c. Final

d. Static

Your answer is correct.



The correct answer is: Synchronized

Privacy Policy
Powered by TEKSTAC

Social Media Policy

You might also like