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

Quiz: Memory and Smart Pointers · Question 3 of 10

Which correctly frees memory from new int[50]?

Which correctly frees memory from new int[50]?

  1. A.delete p;
  2. B.delete[] p;
  3. C.free(p);
  4. D.p = nullptr;
Answer & explanation

Correct answer: delete[] p;

Arrays allocated with new[] must be freed with delete[].

Can you get the rest right without peeking?

Take the timed Quiz: Memory and Smart Pointers quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →