Subject / 929 questions

Programming MCQs

Page 8 of Programming multiple-choice questions with answers. Tap an option to check yourself.

Page 8 of 47

Question 142 C++

Two C++ functions have the same name and the same parameter list but different return types. What happens?

Correct answer B. Compilation fails because functions cannot be overloaded on return type alone

Open question
Advertisement
Question 145 C++

Why should a base class intended for polymorphic use have a virtual destructor?

Correct answer A. So that deleting a derived object through a base pointer runs the derived destructor

Open question
Advertisement
Question 155 C++

Is the declaration const int& r = 5; valid in C++?

Correct answer B. Yes; a temporary is created and its lifetime is extended to match r

Open question
Advertisement