1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. In C++, a constructor must have:

Added 30 Nov -0001

In C++, a constructor must have:

  1. the same name as the class Correct answer
  2. the name 'init'
  3. a return type of void
  4. the keyword constructor

Correct answer

A. the same name as the class

12 views

MCQSEXAM

Explanation

A constructor carries the class name and has no return type.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? 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