🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.The program crashes immediately
  2. B.placeOrder continues with its next line
  3. C.The error passes up through placeOrder and is caught in main
  4. 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 →