1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. Which task does new perform that malloc does not?

Added 30 Nov -0001

Which task does new perform that malloc does not?

  1. It gives back a void pointer
  2. It never reports failure
  3. It allocates memory on the stack
  4. It runs the object's constructor Correct answer

Correct answer

D. It runs the object's constructor

15 views

MCQSEXAM

Explanation

new allocates storage and then calls the constructor, which malloc never does.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is D? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs