C# MCQ Questions And Answers - Multithreading
This section focuses on "Multithreading" in C#. These Multiple Choice Questions (MCQs) should be practiced to improve the C# skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Threads are ?
A. lightweight processes
B. heavyweight processes
C. Both A and B
D. None of the above
View Answer
Ans : A
Explanation: Threads are lightweight processes
2. The threads created using the Thread class are called the?
A. child threads
B. parent threads
C. base threads
D. None of the above
View Answer
Ans : A
Explanation: The threads created using the Thread class are called the child threads of the main thread.
3. Which method for making a thread pause for a specific period of time.
A. push()
B. wait()
C. sleep()
D. stack()
View Answer
Ans : C
Explanation: sleep() method for making a thread pause for a specific period of time.
4. Select the type of multitasking methods that exist:
A. process based
B. thread based
C. only process
D. both process & thread based
View Answer
Ans : D
Explanation: There are two distinct types of multitasking: process-based and thread-based.
5. Choose the correct statement about process-based multitasking.
A. A feature that allows our computer to run two or more programs concurrently
B. A program that acts as a small unit of code that can be dispatched by the scheduler
C. Only A program that acts as a small unit of code that can be dispatched by the scheduler
D. Both A feature that allows our computer to run two or more programs concurrently & A program that acts as a small unit of code that can be dispatched by the scheduler
View Answer
Ans : D
Explanation: The process-based multitasking is the feature that allows your computer to run two or more programs concurrently. For example, process-based multitasking allows you to run a word processor at the same time you are using a spreadsheet or browsing the Internet. In process-based multitasking, a program is the smallest unit of code that can be dispatched by the scheduler.
6. Choose the namespace which supports multithreading programming?
A. System.net
B. System.Linq
C. System.Threading
D. All of the above
View Answer
Ans : C
Explanation: The classes that support multithreaded programming are defined in the System.Threading namespace. Thus, you will usually include this statement at the start of any multithreaded program.
7. Which of these keywords are used to implement synchronization?
A. synchronize
B. syn
C. synch
D. synchronized
View Answer
Ans : D
Explanation: synchronized keywords are used to implement synchronization
8. What is synchronization in reference to a thread?
A. It is a process of handling situations when two or more threads need access to a shared resource
B. It is a process by which many threads are able to access the same shared resource simultaneously
C. It is a process by which a method is able to access many different threads simultaneously
D. It is a method that allows too many threads to access any information they require
View Answer
Ans : A
Explanation: When two or more threads need to access the same shared resource, they need some way to ensure that the resource will be used by only one thread at a time, the process by which this is achieved is called synchronization.
9. Which method is called when a thread is blocked from running temporarily?
A. Pulse()
B. PulseAll()
C. Wait()
D. Both A and B
View Answer
Ans : C
Explanation: When a thread is temporarily blocked from running, it calls Wait( ). This causes the thread to go to sleep and the lock for that object to be released, allowing another thread to acquire the lock.
10. The runtime aborts the thread by throwing a ThreadAbortException
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: The runtime aborts the thread by throwing a ThreadAbortException
Discussion