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

Which two methods make a class an iterator?

Which two methods make a class an iterator?

  1. A.init and len
  2. B.getitem and len
  3. C.call and str
  4. D.iter and next
Answer & explanation

Correct answer: iter and next

These two methods are the iterator protocol.

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 →