Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Questions & Answers ? Multithreaded Programming ? 1
C# Questions & Answers – Multithreaded Programming – 1
This section of our 1000+ C# MCQs focuses on multithreaded programming in part one in C# Programming Language.
1. Select the type of multitasking methods that exist:
a) process based
b) thread based
c) only process
d) both process & thread based
Explanation: There are two distinct types of multitasking: process-based and thread-based.
2. 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
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.
3. Choose the statements which indicate the differences between the thread based multitasking and process based multitasking.
a) Process-based multitasking handles the concurrent execution of programs
b) Process-based multitasking handles the concurrent execution of pieces of the same program
c) Thread-based multitasking handles the concurrent execution of programs
d) Thread-based multitasking deals with the concurrent execution of pieces of the same program
Explanation: The differences between process-based and thread-based multitasking can be summarized like this:Process-based multitasking handles the concurrent execution of programs. Thread-based multitasking deals with the concurrent execution of pieces of the same program.
4. What is the advantage of the multithreading program?
a) Enables to utilize the idle and executing time present in most programs
b) Enables to utilize the idle time present in most programs
c) Both Enables to utilize the idle and executing time present in most programs & Enables to utilize the idle time present in most programs
d) Only Enables to utilize the idle time present in most programs
Explanation: The principal advantage of multithreading is that it enables us to write very efficient programs because it lets us utilize the idle time that is present in most programs.
5. Select the two type of threads mentioned in the concept of multithreading:
a) foreground
b) background
c) only foreground
d) both foreground & background
Explanation: None.
6. Number of threads that exists for each of the processes that occurs in the program:
a) at most 1
b) atleast 1
c) only 1
d) both at most 1 & atleast 1
Explanation: All processes have at least one thread for execution, which is usually called the main thread because it is the primary thread that is executed when our program begins. From the main thread, we can create other threads.
7. Choose the namespace which supports multithreading programming?
a) System.net
b) System.Linq
c) System.Threading
d) All of the mentioned
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.
8. What does the following C# code snippet specify?
-
public Thread(ThreadStart start)
a) Defines a thread
b) Declaration of a thread constructor
c) Only Defines a thread
d) Only Defines a thread & Declaration of a thread constructor
Explanation: To create a thread, instantiate an object of type Thread, which is a class defined in System.Threading. The simplest Thread constructor is shown here:
public Thread(ThreadStart start)
Here, start specifies the method that will be called to begin execution of the thread. In other words, it specifies the thread’s entry point.
9. Which of these classes is used to make a thread?
a) String
b) System
c) Thread
d) Runnable
Explanation: The multithreading system is built upon the Thread class, which encapsulates a thread of execution. The Thread class is sealed, which means that it cannot be inherited. Thread defines several methods and properties that help manage threads.
10. On call of which type of method the new created thread will not start executing?
a) Begin()
b) Start()
c) New()
d) All of the mentioned
Explanation: Once created, the new thread will not start running until you call its Start() method, which is defined by Thread.
11. Which of these methods of Thread class is used to Suspend a thread for a period of time?
a) sleep()
b) terminate()
c) suspend()
d) stop()
Explanation: None.