Subject / 929 questions

Programming MCQs

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

Page 5 of 47

Advertisement
Advertisement
Question 90 C Language

In the C statement a = b = c = 4;, why do all three variables receive the value 4?

Correct answer B. Assignment associates right to left, so c = 4 is evaluated first and its value is assigned onward

Open question
Question 91 C++

Why are C++ function and class template definitions normally placed in header files?

Correct answer D. Because the full definition must be visible wherever the template is instantiated

Open question
Question 94 C++

Why is writing using namespace std; in a header file considered bad practice?

Correct answer C. It forces every file that includes the header to import all std names, risking name clashes

Open question
Advertisement
Question 97 C++

Why is operator<< for printing a user-defined type to std::ostream usually written as a non-member (often friend) function?

Correct answer B. Because the left operand is the ostream, not an object of the user's class

Open question
Question 100 C++

What does std::move actually do to its argument?

Correct answer D. It casts it to an rvalue reference so move operations can be selected

Open question