Vous êtes sur la page 1sur 4

Socket Programming and Threading

MCQs:

1-What is true about threads?


a. Threads consumes CPU in best possible manner
b. Threads enables multi-processing.
c. Multi-threading reduces idle time of CPU
d.All
2-What are valid points about thread
a. Thread are subdivision of Process.
b. One or more Threads runs in the context of process.
c. Threads can execute any part of process. And same part of process
d.All

3-Which of these is not a Thread state?


a) New
b) Runnable
c) Sleep
d) Terminated
4-How can Thread go from waiting to runnable state?
a) Notify
b) When sleep time is up
c) Using resume () method when thread was suspended
5- The time required to create a new thread in an existing process is
a) greater than the time required to create a new process
c) less than the time required to create a new process
c) equal to the time required to create a new process
d) none of the mentioned
6-Termination of the process terminates
a) first thread of the process
b) first two threads of the process

c) all threads within the process


d) no thread within the process

7- Thread synchronization is required because


a) all threads of a process share the same address space
b) all threads of a process share the same global variables
c) all threads of a process can share the same files
d) all of the mentioned
8-When the event for which a thread is blocked occurs,
a) thread moves to the ready queue
b) thread remains blocked
c) thread completes
d) a new thread is provided
9- Which of the following will not directly cause a thread to stop?
a)
b)
c)
d)

Notify
Wait
InputStream access
Sleep

10-What state does Thread enter in when it has been created and started?
a) New
b) Runnable
c) Sleep
d) Terminated
11- What are valid point about processes?
a) Processes have their own copy of the data segment of the parent process
b) Threads have direct access to the data segment of its process
c) Processes have their own address
d) All of these
12-How can we create Thread?
a) By Extending Thread class
b) Implementing Runnable interface
c) By using Executor framework - which can internally form threads

d) All
13-A thread can acquire a lock by using which reserved keyword?
a) volatile
b) Synchronized
c) Locked
d) None

14-Which is thread safe?


a) StringBuffer
b) StringBuilder
c) All
d) None
15-synchronized instance methods acquire lock on?
a) Object
b) Runnable
c) Running
d) Waiting
16-What is valid about threads
a) Threads have their own heap allocated area.
b) Threads have their own stack.
c) Threads doesn't have own stack.
d) None
17-How can you ensure all threads that started from main must end in order in which
they started and also main should end in last
a) Join () method
b) sleep () method
c) wait () method
d) run () method
18-What are valid statements for suspend () and resume () method?
a) Suspend() method is deadlock prone.
b) If the target thread holds a lock on object when it is suspended, no thread can
lock this object until the target thread is resumed.

c) If the thread that would resume the target thread attempts to lock this monitor
prior to calling resume, it results in deadlock formation.
d) All
19-What is difference between starting thread with run () and start () method?
a) There is no difference
b) When you call start () method, main thread internally calls run () method to
start newly created Thread
c) Run () calls start() method internally
d) None
20-What state does Thread enter in when it has been created and started?
a) New
b) Runnable
c) Running
d) Waiting

Vous aimerez peut-être aussi