System Programming MCQs with Answers
Practice important System Programming MCQs with answers and explanations.
Chapter: 51
Q1061:
The sys.exit() function is used to ________.
A. terminate the program
B. handle runtime errors
C. cause overflow errors
D. detect system errors
Correct Answer:
A
Chapter: 51
Q1062:
The exception type that handles unexpected errors not classified elsewhere is ________.
A. RuntimeError
B. OSError
C. SystemExit
D. ReferenceError
Correct Answer:
A
Chapter: 51
Q1063:
OSError typically indicates ________.
A. a failure in system level operations
B. an overflow in arithmetic calculations
C. a problem with weak references
D. an internal interpreter fault
Correct Answer:
A
Chapter: 51
Q1064:
OverflowError happens when ________.
A. the result of an arithmetic operation exceeds the allowable range
B. a system operation fails
C. a weak reference is accessed
D. the interpreter encounters an internal fault
Correct Answer:
A
Chapter: 52
Q1065:
In Python exception handling, the block that runs if no exception occurs is called ________.
A. try
B. except
C. else
D. finally
Correct Answer:
C
Chapter: 52
Q1066:
Which block is used to catch a specific exception in Python?
A. try
B. else
C. except
D. finally
Correct Answer:
C
Chapter: 52
Q1067:
The purpose of the try block in Python exception handling is to ________.
A. handle exceptions
B. define variables
C. execute code that may cause exceptions
D. skip errors
Correct Answer:
C
Chapter: 52
Q1068:
If an ExceptionI occurs, which block is executed in the Python exception sequence?
A. try
B. except ExceptionI
C. else
D. finally
Correct Answer:
B
Chapter: 52
Q1069:
The else block in Python exception handling executes when ________.
A. an exception occurs
B. no exception occurs
C. any exception occurs
D. finally block is skipped
Correct Answer:
B
Chapter: 52
Q1070:
In Python, multiple except blocks can be used to handle different ________.
A. exceptions
B. variables
C. functions
D. classes
Correct Answer:
A
Chapter: 52
Q1071:
Which of the following runs regardless of whether an exception occurred or not?
A. try
B. except
C. finally
D. else
Correct Answer:
D
Chapter: 52
Q1072:
In the Python exception handling sequence, the correct order of blocks is ________.
A. try, except, else, finally
B. try, else, except, finally
C. except, try, finally, else
D. finally, try, except, else
Correct Answer:
A
Chapter: 52
Q1073:
When an exception is raised in the try block, Python looks for a matching ________ block.
A. else
B. except
C. finally
D. try
Correct Answer:
B
Chapter: 52
Q1074:
If no exception occurs in the try block, the except blocks are ________.
A. executed
B. skipped
C. partially executed
D. ignored
Correct Answer:
B
Chapter: 52
Q1075:
Which block is mandatory in Python exception handling?
A. try
B. except
C. else
D. finally
Correct Answer:
A
Chapter: 52
Q1076:
The keyword used to catch all exceptions is ________.
A. except
B. try
C. finally
D. else
Correct Answer:
A
Chapter: 52
Q1077:
When an exception is caught in except block, the program ________.
A. terminates
B. continues execution
C. with error warning
D. restarts
Correct Answer:
B
Chapter: 52
Q1078:
If you want to execute cleanup code regardless of exceptions, you should use the ________ block.
A. except
B. finally
C. else
D. try
Correct Answer:
B
Chapter: 52
Q1079:
You want to catch both ExceptionI and ExceptionII separately, you should use ________.
A. two try blocks
B. two else blocks
C. two except blocks
D. two finally blocks
Correct Answer:
C
Chapter: 52
Q1080:
Code inside the try block is executed ________.
A. before exception handling
B. only if no exceptions occur
C. always
D. until exception occurs
Correct Answer:
D