Object Oriented Programming MCQs with Answers
Practice important Object Oriented Programming MCQs with answers and explanations.
Multiple Choice Questions
Q651: What is an example of abnormal termination in error handling?
- A: Returning an error code
- B: Graceful exit
- C: Immediate program termination
- D: Exception handling
View Answer
C
Q652: What does graceful termination in error handling involve?
- A: Immediate exit without cleanup
- B: Exiting after cleanup
- C: Ignoring errors
- D: Crashing the system
View Answer
B
Q653: What happens when a program uses return with an illegal value for error handling?
- A: Program crashes immediately
- B: Program exits gracefully
- C: Program continues with modified data
- D: Program displays an error message
View Answer
C
Q654: What is the output when a denominator is zero in a program with graceful termination?
- A: Program terminates abnormally
- B: Clean exit with an error message
- C: The program continues as normal
- D: Data loss occurs
View Answer
B
Q655: In exception handling, what is the purpose of the try block?
- A: To execute code that might cause an exception
- B: To catch exceptions
- C: To throw exceptions
- D: To handle program crashes
View Answer
A
Q656: How is an exception thrown in C++?
- A: Using the throw keyword
- B: Using the catch keyword
- C: Using the return statement
- D: Using the exit function
View Answer
A
Q657: What is the role of the catch block in exception handling?
- A: To execute code that might cause an exception
- B: To catch exceptions thrown in the try block
- C: To terminate the program
- D: To initialize variables
View Answer
B
Q658: What is an example of an object used to represent an exception in C++?
- A: DivideByZero class
- B: ErrorHandler class
- C: ErrorCode class
- D: Exception class
View Answer
A
Q659: What happens if a function returns false for error handling?
- A: The function is retried
- B: The program crashes
- C: The error is handled gracefully
- D: The error message is displayed
View Answer
C
Q660: Which error handling technique involves separating error handling code from main logic?
- A: Graceful termination
- B: Abnormal termination
- C: Exception handling
- D: Returning illegal values
View Answer
C