🎙 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 5 of 10

Why throw new Error("…") instead of throw "failed"?

Why throw new Error("…") instead of throw "failed"?

  1. A.Strings cannot be thrown
  2. B.Error objects carry a name and a stack trace that show where the problem happened
  3. C.It is faster
  4. D.Strings are caught twice
Answer & explanation

Correct answer: Error objects carry a name and a stack trace that show where the problem happened

Without the stack, finding the source of a thrown string is much harder.

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 →