← Quiz: Error Handling and Debugging: all 10 questions
Quiz: Error Handling and Debugging · Question 7 of 10
placeOrder() calls chargeCard(), which throws. Only main() has a try/catch around placeOrder(). What happens?
placeOrder() calls chargeCard(), which throws. Only main() has a try/catch around placeOrder(). What happens?
- A.The program crashes immediately
- B.placeOrder continues with its next line
- C.The error passes up through placeOrder and is caught in main
- D.chargeCard retries automatically
Answer & explanation
Correct answer: The error passes up through placeOrder and is caught in main
Errors travel up the call stack until a catch handles them; code in between stops.
Can you get the rest right without peeking?
Take the timed Quiz: Error Handling and Debugging quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →