System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 13
Q341:
The dwFlagsAndAttributes parameter is used to specify _______.
A. Security attributes
B. File size
C. File attributes and flags
D. File handle
Correct Answer:
C
Chapter: 13
Q342:
The hTemplateFile parameter is used to _______.
A. Specify file security
B. Specify attributes to apply to new file
C. Specify file size
D. Specify access rights
Correct Answer:
B
Chapter: 13
Q343:
lpSecurityAttributes points to _______.
A. File name structure
B. File size structure
C. Security attributes structure
D. File handle structure
Correct Answer:
C
Chapter: 13
Q344:
Setting dwShareMode to FILE_SHARE_WRITE allows sharing the file for _______.
A. Reading only
B. Writing only
C. Both reading and writing
D. No sharing
Correct Answer:
B
Chapter: 13
Q345:
If CreateFile() fails to open or create a file, it returns _______.
A. NULL
B. -1
C. INVALID_HANDLE_VALUE
Correct Answer:
C
Chapter: 14
Q346:
What is the purpose of the ReadFile() API?
A. Read data from buffer to file
B. Write data to file
C. Read data from file to buffer
D. Close a file
Correct Answer:
C
Chapter: 14
Q347:
If ReadFile() reaches the End of File, the number of bytes read is set to _______.
A. -1
B. 1
D. EOF marker
Correct Answer:
C
Chapter: 14
Q348:
Which parameter of ReadFile() holds the file handle?
A. lpBuffer
B. hFile
C. nNumberOfBytesToRead
D. lpOverlapped
Correct Answer:
B
Chapter: 14
Q349:
The parameter lpBuffer in ReadFile() is used to _______.
A. Store the file handle
B. Store data read from the file
C. Count bytes to read
D. Control concurrent processing
Correct Answer:
B
Chapter: 14
Q350:
What does nNumberOfBytesToRead specify in ReadFile()?
A. Number of bytes to write
B. Number of bytes to read
C. Buffer size
D. Number of bytes read
Correct Answer:
B
Chapter: 14
Q351:
ReadFile() returns FALSE when _______.
A. File is at EOF
B. A parameter is invalid
C. Read is successful
D. Bytes read is zero
Correct Answer:
B
Chapter: 14
Q352:
lpNumberOfBytesRead in ReadFile() API is used to _______.
A. Store the number of bytes requested
B. Store the number of bytes actually read
C. Store the file size
D. Store the file handle
Correct Answer:
B
Chapter: 14
Q353:
What is the role of the LPOVERLAPPED parameter?
A. For file security
B. For file naming
C. For concurrent processing
D. For error handling
Correct Answer:
C
Chapter: 14
Q354:
WriteFile() API is used to _______.
A. Read data from buffer to file
B. Write data from buffer to file
C. Read data from file to buffer
D. Close a file
Correct Answer:
B
Chapter: 14
Q355:
To write through the current size of the file, the file must be opened with _______.
A. FILE_FLAG_OVERLAPPED
B. FILE_FLAG_WRITE_THROUGH
C. FILE_SHARE_WRITE
D. FILE_SHARE_READ
Correct Answer:
B
Chapter: 14
Q356:
Which parameter in WriteFile() specifies how many bytes are written?
A. lpBuffer
B. lpNumberOfBytesWritten
C. nNumberOfBytesToWrite
D. hFile
Correct Answer:
B
Chapter: 14
Q357:
The WriteFile() API returns FALSE when _______.
A. File is not opened in write mode
B. Any parameter is invalid
C. Write is successful
D. Bytes written is zero
Correct Answer:
A
Chapter: 14
Q358:
The WriteFile() function's lpBuffer parameter holds _______.
A. File handle
B. Data to write
C. File size
D. Number of bytes to write
Correct Answer:
B
Chapter: 14
Q359:
If ReadFile() succeeds but reads zero bytes, it indicates _______.
A. Invalid parameters
B. End of file
C. Write failure
D. Buffer overflow
Correct Answer:
B
Chapter: 14
Q360:
ReadFile() and WriteFile() APIs are synchronous by default unless used with _______.
A. FILE_FLAG_WRITE_THROUGH
B. FILE_FLAG_OVERLAPPED
C. CREATE_NEW
D. OPEN_EXISTING
Correct Answer:
B