System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 18
Q401:
The use of Unicode-only strategy is _______.
A. Decreasing in popularity
B. Increasing in popularity
C. No longer used
D. Only for legacy code
Correct Answer:
B
Chapter: 18
Q402:
Using generic code makes the program _______.
A. Less flexible
B. More flexible
C. Slower
D. Incompatible
Correct Answer:
B
Chapter: 19
Q403:
Which Windows function returns the code for the last system error?
A. GetErrorCode()
B. GetLastError()
C. FormatMessage()
D. LocalFree()
Correct Answer:
B
Chapter: 19
Q404:
The function that translates an error code into a readable message is _______.
A. GetLastError()
B. FormatMessage()
C. LocalFree()
D. ErrorTranslator()
Correct Answer:
B
Chapter: 19
Q405:
What is the purpose of LocalFree() in error reporting?
A. Allocate memory
B. Deallocate memory
C. Translate error code
D. Return error code
Correct Answer:
B
Chapter: 19
Q406:
Windows Operating System provides error reporting mainly for _______.
A. User convenience
B. System security
C. File management
D. Network monitoring
Correct Answer:
A
Chapter: 19
Q407:
GetLastError() returns _______.
A. The last system error code
B. A pointer to the error message
C. A boolean value
D. Error severity level
Correct Answer:
A
Chapter: 19
Q408:
FormatMessage() converts error codes into _______.
A. Binary code
B. Meaningful English or user language
C. Text file
D. Hexadecimal values
Correct Answer:
B
Chapter: 19
Q409:
A message string reference for an error code is stored in a _______ when using FormatMessage().
A. Error log file
B. Parameter
C. Function
D. Return value
Correct Answer:
B
Chapter: 19
Q410:
Windows error reporting helps to improve _______.
A. Program performance
B. User convenience
C. Internet speed
D. File size
Correct Answer:
B
Chapter: 19
Q411:
Which function should be called after FormatMessage() to avoid memory leaks?
A. LocalFree()
B. GetLastError()
C. FreeMemory()
D. ReleaseMessage()
Correct Answer:
A
Chapter: 20
Q412:
Which two header files must be included for error reporting functions in the example?
A. <windows.h> and <tchar.h>
B. <environment.h> and <everything.h>
C. <stdio.h> and <stdlib.h>
D. <error.h> and <sys.h>
Correct Answer:
B
Chapter: 20
Q413:
In the ReportError() function, which function retrieves the last system error code?
A. GetLastError()
B. FormatMessage()
C. LocalFree()
D. ExitProcess()
Correct Answer:
A
Chapter: 20
Q414:
What type of variable is used to store the last error code in ReportError()?
A. DWORD
B. BOOL
C. LPCTSTR
D. LPTSTR
Correct Answer:
A
Chapter: 20
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
Correct Answer:
A
Chapter: 20
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
Correct Answer:
B
Chapter: 20
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
Correct Answer:
A
Chapter: 20
Q418:
Which function is used to free the memory allocated by FormatMessage()?
A. LocalFree()
B. FreeBuffer()
C. ReleaseMemory()
D. FreeFormatMessage()
Correct Answer:
A
Chapter: 20
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
Correct Answer:
B
Chapter: 20
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
Correct Answer:
B