Class XII Computer Science Chapter 1 MCQs (Difficulty-wise) — Exception Handling
Use this page if you want a structured path: start with basic definitions, then practise common exception types and control flow in try/except/else/finally.
Easy (Basics)
1) Which keyword is used to handle exceptions?
A. catch
B. except
C. handle
D. error
Correct Answer: B
2) Which exception occurs for 10/0?
A. TypeError
B. ValueError
C. ZeroDivisionError
D. NameError
Correct Answer: C
3) What does raise do?
A. handles an exception
B. throws an exception
C. prints an error
D. stops Python from showing traceback
Correct Answer: B
4) finally block runs
A. only on success
B. only on failure
C. regardless of exception (cleanup)
D. only with assert
Correct Answer: C
5) int('12a') raises
A. ValueError
B. TypeError
C. NameError
D. KeyError
Correct Answer: A
6) Accessing L[5] when L has length 2 raises
A. KeyError
B. IndexError
C. NameError
D. ImportError
Correct Answer: B
Revision Tip: Learn exceptions by examples (divide by zero, wrong type, wrong index, missing key). That’s exactly how MCQs test them.
Medium (Control Flow)
7) In try/except/else, the else block runs when
A. an exception occurs
B. no exception occurs in try
C. always
D. only if finally is missing
Correct Answer: B
8) What happens when an exception is raised inside try?
A. remaining statements in try continue
B. control jumps to matching except
C. Python ignores it
D. program restarts
Correct Answer: B
9) Which is correct syntax?
A. try: ... catch: ...
B. try: ... except: ...
C. attempt: ... except: ...
D. try: ... handle: ...
Correct Answer: B
10) If no matching handler is found, Python will
A. continue silently
B. stop and show a traceback
C. auto-fix the error
D. convert to warning
Correct Answer: B
11) assert condition raises
A. ValueError
B. AssertionError when condition is false
C. TypeError always
D. nothing
Correct Answer: B
12) d['x'] when key 'x' is missing raises
A. KeyError
B. IndexError
C. NameError
D. ValueError
Correct Answer: A
Hard (Exam-Style Reasoning)
13) Best practice for exception handling is
A. except: everywhere
B. catch specific exception types you expect
C. avoid exceptions entirely
D. always suppress errors
Correct Answer: B
14) What exception occurs when you do 3 + '4'?
A. TypeError
B. ValueError
C. NameError
D. KeyError
Correct Answer: A
15) If you want a “cleanup” statement to run even if an exception occurs, you should use
A. else
B. finally
C. assert
D. raise
Correct Answer: B
16) Which is true?
A. finally runs only on exception
B. finally runs only when there is no exception
C. finally runs in both cases
D. finally replaces except
Correct Answer: C
17) try block is used to
A. write comments
B. test code that may raise exceptions
C. convert Python to C++
D. declare variables
Correct Answer: B
18) If an exception is caught in except, then
A. Python always terminates immediately
B. program can continue after the try/except block
C. except block is skipped
D. the exception must be re-raised
Correct Answer: B