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

Quiz: Copy Constructor and Deep Copy · Question 4 of 10

Why is a shallow copy dangerous for a class whose destructor does delete[] data?

Why is a shallow copy dangerous for a class whose destructor does delete[] data?

  1. A.It uses too much memory
  2. B.It is slower than a deep copy
  3. C.Both objects delete the same array when destroyed — a double delete
  4. D.The destructor is never called
Answer & explanation

Correct answer: Both objects delete the same array when destroyed — a double delete

Two owners of one block means two deletes, which is undefined behaviour.

Can you get the rest right without peeking?

Take the timed Quiz: Copy Constructor and Deep Copy quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →