System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Multiple Choice Questions
Q411: Which function should be called after FormatMessage() to avoid memory leaks?
- A: LocalFree()
- B: GetLastError()
- C: FreeMemory()
- D: ReleaseMessage()
View Answer
A
Q412: Which two header files must be included for error reporting functions in the example?
- A:
and - B:
and - C:
and - D:
and
View Answer
B
Q413: In the ReportError() function, which function retrieves the last system error code?
- A: GetLastError()
- B: FormatMessage()
- C: LocalFree()
- D: ExitProcess()
View Answer
A
Q414: What type of variable is used to store the last error code in ReportError()?
- A: DWORD
- B: BOOL
- C: LPCTSTR
- D: LPTSTR
View Answer
A
Q415: What is the role of the variable lpvSysMsg in ReportError()?
- A: Stores a formatted error string
- B: Stores the exit code
- C: Holds the user message
- D: Stores the error number
View Answer
A
Q416: The FormatMessage() function is called with which flag to allocate buffer memory?
- A: FORMAT_MESSAGE_IGNORE_INSERTS
- B: FORMAT_MESSAGE_ALLOCATE_BUFFER
- C: FORMAT_MESSAGE_FROM_STRING
- D: FORMAT_MESSAGE_ARGUMENT_ARRAY
View Answer
B
Q417: What happens if FormatMessage() returns a length greater than 0?
- A: The error message is printed
- B: The error code is ignored
- C: The program exits
- D: Memory is freed
View Answer
A
Q418: Which function is used to free the memory allocated by FormatMessage()?
- A: LocalFree()
- B: FreeBuffer()
- C: ReleaseMemory()
- D: FreeFormatMessage()
View Answer
A
Q419: If printErrorMessage is FALSE, what does ReportError() do?
- A: Prints only userMessage
- B: Formats the error code
- C: Prints error message and code
- D: Exits process
View Answer
B
Q420: What does ReportError() do if exitCode is greater than zero?
- A: Returns without exiting
- B: Exits the process with the exitCode
- C: Prints error and continues
- D: Throws an exception
View Answer
B