🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Memory and Smart Pointers: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Which smart pointer should be your default choice?
  2. Q2. What happens when you try to copy a uniqueptr?
  3. Q3. Which correctly frees memory from new int[50]?
  4. Q4. What does RAII guarantee?
  5. Q5. What does this print? (code)
  6. Q6. What does this print? (code)
  7. Q7. How do you hand ownership from one uniqueptr to another?
  8. Q8. Two objects hold sharedptrs to each other. What goes wrong?
  9. Q9. Why prefer makeunique<Student() over uniqueptr<Student(new Student())?
  10. Q10. Which exception does vector::at(i) throw when i is outside the vector?