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

Quiz: C++ Interview Questions · Question 5 of 10

What does new do that malloc doesn't?

What does new do that malloc doesn't?

  1. A.Allocates on the stack
  2. B.Calls the constructor and returns a typed pointer
  3. C.Frees memory automatically
  4. D.Nothing — they are identical
Answer & explanation

Correct answer: Calls the constructor and returns a typed pointer

new constructs the object; malloc only allocates raw bytes.

Can you get the rest right without peeking?

Take the timed Quiz: C++ Interview Questions quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →