🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Exceptions in Depth: all 10 questions

Quiz: Exceptions in Depth · Question 8 of 10

What does this print? (code)

What does this print?

class AppError(Exception):
    pass
class LoginError(AppError):
    pass
try:
    raise LoginError("wrong password")
except AppError as e:
    print(type(e).__name__, e)
  1. A.AppError wrong password
  2. B.LoginError wrong password
  3. C.wrong password
  4. D.An error
Answer & explanation

Correct answer: LoginError wrong password

except AppError catches its subclass, and e is still the LoginError object.

Can you get the rest right without peeking?

Take the timed Quiz: Exceptions in Depth quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →