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

What does this print? (code)

What does this print?

function f() {
  try { return "try"; }
  finally { console.log("cleanup"); }
}
console.log(f());
  1. A.try
  2. B.cleanup
  3. C.cleanup try
  4. D.try cleanup
Answer & explanation

Correct answer: cleanup try

finally runs before the function actually returns, so "cleanup" prints first, then the returned "try".

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 →