System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 120
Q2601:
In the code example, a subarray is sorted with qsort(), which is a ______ function.
A. standard library
B. user-defined
C. custom
D. multithreaded
Correct Answer:
A
Chapter: 121
Q2602:
What is the main advantage of using multiple threads in MergeSort?
A. Simplifies code
B. Reduces sorting time by parallelism
C. Uses less memory
D. Avoids file I/O
Correct Answer:
B
Chapter: 121
Q2603:
In the MergeSort multi-thread program, what must the number of threads be?
A. Any positive integer
B. A prime number
C. A power of 2
D. An odd number
Correct Answer:
C
Chapter: 121
Q2604:
What does the program require about the number of 64-byte records in the file?
A. Must be a prime number
B. Must be multiple of number of threads
C. Must be even
D. No restriction
Correct Answer:
B
Chapter: 121
Q2605:
What does 'SortThread' function do in this program?
A. Creates threads
B. Sorts a portion of the array
C. Merges arrays
D. Allocates memory
Correct Answer:
B
Chapter: 121
Q2606:
What Windows API function is used to map a file to memory in this program?
A. CreateFileMapping
B. CreateThread
C. ReadFile
D. WriteFile
Correct Answer:
A
Chapter: 121
Q2607:
What does the 'KeyCompare' function compare?
A. Data fields
B. Record sizes
C. Keys of records
D. Number of threads
Correct Answer:
C
Chapter: 121
Q2608:
How does the program ensure threads merge sorted parts correctly?
A. Using file pointers
B. Threads wait for adjacent thread
C. Using random access
D. Using external memory
Correct Answer:
B
Chapter: 121
Q2609:
Which function is responsible for merging two adjacent sorted arrays?
A. SortThread
B. MergeArrays
C. KeyCompare
D. MapViewOfFile
Correct Answer:
B
Chapter: 121
Q2610:
What happens if the number of threads exceeds the number of processors?
A. Performance improves
B. No effect
C. Performance degrades
D. Threads run sequentially
Correct Answer:
C
Chapter: 121
Q2611:
What is the purpose of the 'threadArg' structure?
A. Stores thread return values
B. Passes thread number and record range
C. Manages memory allocation
D. Handles error reporting
Correct Answer:
B
Chapter: 121
Q2612:
What does the program do if the input file cannot be opened?
A. Creates a new file
B. Prints an error and exits
C. Ignores error
D. Retries opening file
Correct Answer:
B
Chapter: 121
Q2613:
The file is sorted in place, meaning:
A. The original file is replaced
B. A new file is created
C. Sorting is done in memory
D. Sorting is done on disk
Correct Answer:
C
Chapter: 121
Q2614:
How does the program handle printing the sorted file?
A. Writes to console
B. Saves to new file
C. Prints all records as string
D. Sends to network
Correct Answer:
C
Chapter: 121
Q2615:
What does the variable 'nRecTh' represent in the program?
A. Number of threads
B. Number of records per thread
C. Total number of records
D. Number of processors
Correct Answer:
B
Chapter: 121
Q2616:
What function is used to create new threads suspended initially?
A. CreateThread
B. _beginthreadex
C. ResumeThread
D. WaitForSingleObject
Correct Answer:
B
Chapter: 121
Q2617:
What synchronization method is used to wait for thread completion before merging?
A. Sleep
B. WaitForSingleObject
C. Mutex lock
D. Critical section
Correct Answer:
B
Chapter: 121
Q2618:
When merging arrays, what is used to store temporary merged data?
A. Static array
B. Dynamically allocated memory
C. File buffer
D. Thread stack
Correct Answer:
B
Chapter: 121
Q2619:
What is the reason for restoring file length at the end of the program?
A. To remove extra bytes added earlier
B. To resize file for new data
C. To prevent file corruption
D. To reset file pointer
Correct Answer:
A
Chapter: 121
Q2620:
If memory is insufficient, what problem might occur during multithreaded sorting?
A. Threads crash
B. Performance degrades due to contention
C. Incorrect results
D. Deadlock
Correct Answer:
B