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

Quiz: Context Managers · Question 2 of 10

Which two methods make an object a context manager?

Which two methods make an object a context manager?

  1. A.init and del
  2. B.iter and next
  3. C.enter and exit
  4. D.open and close
Answer & explanation

Correct answer: enter and exit

enter runs at the start and exit at the end of the with block.

Can you get the rest right without peeking?

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

Start the quiz →