Computer Science - Object Oriented Programming Using C++

21. 

The #ifndef directive tests to see whether ________

A. a class has been defined
B. a variable has been given a value
C. a class has no variable definitions
D. any objects of the class have been instantiated

Answer: Option A

Explanation:

#ifndef checks whether the given token has been #defined earlier in the file or in an included file; if not, it includes the code between it and the closing #else or, if no #else is present, #endif statement. #ifndef is often used to make header files idempotent by defining a token once the file has been included and checking that the token was not set at the top of that file.


22. 

Which of the following statements is false?

A. A function is a block of code that performs a specific task
B. Functions allow programmers to break large and complex problems into small and manageable tasks
C. Functions allow programmers to use existing code to perform common tasks
D. Functions can be called, or invoked, only once in a program
E. Programmer-defined functions can be either value-returning or void

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.

23. 

The generic type in a template function

A. must be T
B. can be T
C. cannot be T for functions you create, but may be for C++'s built-in functions
D. cannot be T

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.

24. 

When a child class function is called, the compiler looks first for a matching function name in the _____

A. class of the object using the function name
B. immediate ancestor class
C. base class
D. descendant class

Answer: Option A

Explanation:

No answer description available for this question. Let us discuss.

25. 

A function that is called automatically each time an object is destroyed is a

A. constructor
B. destructor
C. destroyer
D. terminator

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.