Please answer all questions. Beginning Java with NetBeans: Chapter 18 How to wor
ID: 3737495 • Letter: P
Question
Please answer all questions.
Beginning Java with NetBeans: Chapter 18
How to work with threads
MULTIPLE CHOICE
[Answers are in tables – delete all but the correct answer’s cell]
What part of the operating system controls the execution of threads?
a.
thread scheduler
c.
task controller
b.
execution scheduler
d.
run scheduler
Which of the following is not one of the typical uses for threads?
a.
To improve the speed of numeric computations
b.
To improve the performance of applications with extensive I/O operations
c.
To allow two or more users to run server-based applications simultaneously
d.
To improve the responsiveness of GUI applications
Which of the following interfaces can be used to create a thread?
a.
Thread
c.
Scheduler
b.
Runnable
d.
Task
Which of the following is not one of the valid states of a thread?
a.
New
d.
Blocked
b.
Runnable
e.
Waiting
c.
Running
Which statement most accurately describes a thread in the Runnable state?
a.
The thread is available for execution, but is not yet executing.
b.
The thread is either available for execution or is currently executing.
c.
The thread has been created but its start method has not yet been called.
d.
The thread’s sleep method has been called.
Which package is the Thread class stored in?
a.
java.threading
c.
java.system
b.
java.lang
d.
java.task
What method do you override to provide the code that’s executed by a thread?
a.
exec
c.
run
b.
start
d.
task
Consider the following program:
public class CountDownApp {
public static void main(String[] args) {
Thread t1 = new CountDown();
Thread t2 = new CountDown();
t1.start();
t2.start();
}
}
Assuming that the CountDown class extends the Thread class, how many threads are used to run this program?
a.
1
c.
3
b.
2
d.
4
How long will a thread that executes the following statement sleep?
Thread.sleep(50);
a.
exactly 50 milliseconds
c.
at least 50 milliseconds
b.
at most 50 milliseconds
d.
none of the above
What exception is thrown by the sleep method?
a.
InterruptedException
c.
ThreadPausedException
b.
NoSuchThreadException
d.
ThreadException
Which of the following shows the proper position of the synchronized keyword in a class declaration?
a.
public int synchronized calculate(int x)
b.
public synchronized int calculate(int x)
c.
public int calculate(synchronized int x)
d.
public int calculate(int x) synchronized
Which of the following situations would indicate that a method does not need to be synchronized?
a.
The method doesn’t accept parameters.
b.
The method doesn’t have a return value.
c.
The method contains only a single Java statement.
d.
The method will never be called by more than one thread.
Which of the following statements is true when a method specifies the synchronized keyword?
a.
The entire object will be locked whenever any thread executes the method, so even unsynchronized methods are unavailable until the synchronized method finishes.
b.
All other threads in the application will be suspended until the synchronized method completes.
c.
Only one thread at a time will be allowed to execute the method. Any other threads that attempt to execute the method will be forced to wait until the method finishes for the current thread.
d.
Multiple threads can execute the method simultaneously. The task scheduler will automatically switch the execution among the various threads.
COMPLETION
A/an ________________ is a single sequential flow of control within an application that often completes a specific task.
________________ threads execute independently of each other.
a.
thread scheduler
c.
task controller
b.
execution scheduler
d.
run scheduler
Explanation / Answer
Hi, I have answered first 5 Questions.
Please repost others in separate post.
What part of the operating system controls the execution of threads?
Ans: c.task controller
Which of the following is not one of the typical uses for threads?
Ans: To allow two or more users to run server-based applications simultaneously
Which of the following interfaces can be used to create a thread?
Ans: b.Runnable
Which of the following is not one of the valid states of a thread?
ANs: a.New
Which statement most accurately describes a thread in the Runnable state?
Ans: a.The thread is available for execution, but is not yet executing.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.