Multiple Choice 1. (TCO 4) C++ supports _____. (Points : 4) both single and mult
ID: 3529376 • Letter: M
Question
Multiple Choice
1. (TCO 4) C++ supports _____. (Points : 4) both single and multiple inheritanceonly single inheritance
only multiple inheritance
neither singlenor multiple inheritance
2. (TCO 4) The constructors of a derived class _____. (Points : 4) cannot directly initializeprivate members that are inherited from the base class
can directly initialize any members that are inherited from the base class
cannot directly initializepublic members that are inherited from the base class
can directly initializeprivate member functionsthat are inherited from the base class
3. (TCO 4) Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass? (Points : 4) class dClass:: public bClass{ //classMembersList};
class dClass: private bClass{ //classMembersList};
class dClass:: protected bClass{ //classMembersList};
class bClass: public dClass{ //classMembersList};
4. (TCO 5)Considerthe following declaration.
int num = 6;
int *p = #
Which statement correctly increments the value of num to a value of 7? (Points : 4) p++;
(*p)++;
(*num)++;
p&num++;
5. (TCO 5) When a class uses dynamic memory allocation, the destructor of the class must _____. (Points : 4) set all dynamically allocated data to zero
return any dynamically allocated memory to the system
explicitly destroy all the objects of the class
All of the above
6. (TCO 5) Which of the following statements correctly allocates space to store 15 real numbers? (Points : 4) double *dptr = new double[15];
double dptr = new double[15];
double *dptr = new double[14];
real *iptr = new real[14];
7. (TCO 5) Which of the following is not a legal value to initialize a pointer variable? (Points : 4) zero
null
0
The address of a variable of the same type
8. (TCO 6) The return type of the function operator == is ____. (Points : 4) int
char
bool
void
9. (TCO 6) If a pointer of type double is declared (as shown below), which is the correct syntax to allocate memory for 10 double variables?
double * ptr; (Points : 4) *ptr = new double [10];
ptr = new [10];
ptr = new double [10];
ptr = new [10] double;
10. (TCO 6) If a class uses dynamic memory allocation, which statement is true? (Points : 4) It must not use dynamic memory allocation in a copy constructor.
All the allocated memory must be deallocated before the object goes out of scope and the destructor is called.
It must not overload the assignment operator.
It must include the dynamic allocation in all theconstructors, and it must then deallocate all of the allocated memory in the destructor.
11. (TCO 6) Which of the following operators can be overloaded? (Points : 4) .
.*
::
++
12. (TCO 7) Which term designates the ability to combine data and operations on that data in a single unit? (Points : 4) Inheritance
Encapsulation
Polymorphism
Composition.
13. (TCO 7) If the class Shape is an abstract class, what type of variable may be declared of the type Shape? (Points : 4) No variables may be declared because it is an abstract class.
Only arrays of the class Shape may be declared.
Objects of the class Shape may be declared only if an object of a class that is derived from Shape is also declared.
A pointer of the abstract class may be declared.
14. (TCO 7)Consider the following class definitions.
class Employee { };
class Boss : public Employee { };
class Worker : public Employee { };
If the function double CalculateEarnings(); is declared as virtual in the class Employee, which class then becomes abstract? (Points : 4) Boss
Employee
Worker
Both Boss and Worker
15. (TCO 7) Virtual functions are reserved using what C++ keyword? (Points : 4) Polymorphic
Static
Dynamic
Virtual
16. (TCO 7) Another definition for dynamic binding is _____. (Points : 4) late binding
early binding
dynamic allocation
It is not a defined term in C++ programming.
17. (TCO 8) Which is a correct preprocessor directive statement? (Points : 4) define PI = 3.141593
define PI = 3.141593;
#define PI 3.141593
#define PI = 3.141593
18. (TCO 8) Which preprocessor directive is used to end a conditional compilation directive? (Points : 4) define
ifndef
ifdef
endif
19. (TCO 8) All preprocessor directives begin with a(n) ___. (Points : 4) underscore
blank space
#
&
20. (TCO 8) What is a preprocessor directive? (Points : 4) An instruction to the preprocessor
An instruction to the linker
An instruction to the debugger
An instruction to the compiler
Explanation / Answer
both single and multiple inheritance
can directly initializeprivate member functionsthat are inherited from the base class
class dClass:: public bClass{ //classMembersList};
p++;
All of the above
double *dptr = new double[15];
null
char
*ptr = new double [10];
It must include the dynamic allocation in all theconstructors, and it must then deallocate all of the allocated memory in the destructor.
++
Encapsulation
Only arrays of the class Shape may be declared.
Both Boss and Worker
Polymorphic
dynamic allocation
#define PI = 3.141593
endif
#
An instruction to the compiler
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.