Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

QUESTION 21 Multithreading is supported by the Thread interface Runnable class a

ID: 3598573 • Letter: Q

Question

QUESTION 21

Multithreading is supported by the

Thread interface

Runnable class and the Thread interface

Thread class and the Runnable interface

Runnable class

1 points   

QUESTION 22

When creating a runnable object, why might you want to extend Thread rather than implement Runnable?

When you want to override one or more of Thread’s methods other than run().

When you want to overload one or more of Thread’s methods such as run()

Both a and b are correct

When you want to instantiate the runnable object.

1 points   

QUESTION 23

Show how to use join() to wait for a thread object called MyThrd to end

Object MyThrd = MyThrd.join();

MyThrd.join();

Thread MyThrd.join();

join().MyThrd;

1 points   

QUESTION 24

Show how to set a thread called MyThrd to three levels above normal priority

MyThrd.setPriority(Above.NORM_PRIORITY, 3);

MyThrd.setPriority(Thread.NORM_PRIORITY , 3);

MyThrd.setPriority(Above.NORM_PRIORITY + 3);

MyThrd.setPriority(Thread.NORM_PRIORITY + 3);

1 points   

QUESTION 25

Adding synchronized to a method allows only one thread at a time to use the method for any given object of its class.

True

False

1 points   

QUESTION 26

The wait() and notify() methods are used to perform

innerthread communication

interthread communication

outerthread communication

synchronized communication

1 points   

QUESTION 27

What method defined by Thread obtains the name of a thread?

readName()

loadName()

setName()

getName()

1 points   

QUESTION 28

What does isAlive() return?

true if the invoking thread is still running

true if the invoking thread has been initialized

false if the invoking thread has been terminated

either A or C

1 points   

QUESTION 29

Why can’t you use suspend(), resume(), and stop() for new programs?

The three methods have been deprecated because they can cause serious run-time problems.

You can you use suspend(), resume(), and stop() for new programs with no problems

The three methods have been deprecated because they can cause serious logic problems.

The three methods have been deprecated because they can cause serious compile-time problems

1 points   

QUESTION 30

Exception UnknownHostException occurs when

a hostname not indicated by a client cannot be resolved to an address.

a hostname indicated by a client cannot be resolved to an address.

a client name indicated by a host cannot be resolved to an address.

a client name not indicated by a host can be resolved to an address.

a.

Thread interface

b.

Runnable class and the Thread interface

c.

Thread class and the Runnable interface

d.

Runnable class

Explanation / Answer

21). C (Thread class and runnable iterface)

eg: class Multi extends Thread{} -> for Thread class

class Multi implements Runnable{} -> for Runnable interface

22). A (When you want to override one or more Thread's methods other than run()). We use Thread class when we want to modify or add functionality to Thread methods.

23). B (MyThd.join();).

24). D (MyThrd.setPriority(Thread.NORM_PRIORITY+3);)

25). TRUE (Adding sychronized on a method means the thread has to acquire the lock on the object instance before entering that method, so if you have two different methods marked synchronized the threads entering them will be fighing for the same lock, and once one thread gets the lock all other threads are shut out of all methods that synchronize on that same lock).

26). B (interthread communication). Inter thread communication is a mechanism in which a thread is paused and another thread is executed.

27). D (getName())

28). D (either A or C).

29). A (The three methods have been deprecated because they can cause serious run-time problems.)

30). B (a hostname indicated by a client cannot be resolved to an address.)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote