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

Quiz: Iterators and Generators · Question 10 of 10

What is a key difference between return and yield?

What is a key difference between return and yield?

  1. A.yield pauses the function so it can continue later; return ends it
  2. B.return can send only numbers
  3. C.yield can only be used inside a class
  4. D.There is no difference
Answer & explanation

Correct answer: yield pauses the function so it can continue later; return ends it

After yield, local variables are kept and the function resumes from the same place.

Can you get the rest right without peeking?

Take the timed Quiz: Iterators and Generators quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →