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

Quiz: Copy Constructor and Deep Copy: questions with answers

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

Take the timed quiz + get a certificate →
  1. Q1. Which function runs for Student b = a; when b is being declared?
  2. Q2. What does this print? (code)
  3. Q3. What is a shallow copy?
  4. Q4. Why is a shallow copy dangerous for a class whose destructor does delete[] data?
  5. Q5. Why must the copy constructor take its parameter by reference?
  6. Q6. What does the rule of three say?
  7. Q7. What does this print? (code)
  8. Q8. In copy-and-swap, why does operator= take its parameter by value?
  9. Q9. How do you make a class impossible to copy?
  10. Q10. What is the rule of zero?