Question 1. 1. (TCO 4) The ability to create a new class that receives some of i
ID: 3672475 • Letter: Q
Question
Question 1.1. (TCO 4) The ability to create a new class that receives some of its data and function members from a previously defined class is called _____. (Points : 4) InheritanceEncapsulation
Polymorphism
Composition Question 2.2. (TCO 4) The constructors of a derived class _____. (Points : 4) cannot directly initialize private members that are inherited from the base class
can directly initialize any members that are inherited from the base class
cannot directly initialize public members that are inherited from the base class
can directly initialize private member functions that are inherited from the base class Question 3.3. (TCO 4) The existing classes, from which you create new classes, are called the ____ classes. (Points : 4) child
base
sibling
derived Question 4.4. (TCO 5) In the following code, if the address of foo is bff00fa10 hex and the address of foo2 is bff00a14 hex, what would the output be if the line cout << foo2 << endl; were added after the last line?
int foo;
int *foo2;
foo2 = &foo;
foo = 1234;
cout << *foo2 << end1; (Points : 4) 1234
0xbff00a10
0xbff00a14
0xbff01424 Question 5.5. (TCO 5) Consider a class called Employee and the following definitions and statements.
void myFunction( Employee eptr );
Employee *emp = new Employee;
Which statement correctly passes by value the newly created Employee object? (Points : 4) myFunction(emp);
myFunction(&emp);
myFunction(*emp);
None of the above Question 6.6. (TCO 5) What is wrong with the following C++ statements?
int* iptr;
double d = 123.321;
iptr = & d;
cout << *iptr; (Points : 4) The cout statement does not contain an endl.
The space following the ampersand should not be there.
The iptr variable cannot be given an address of a double.
All of the above Question 7.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 Question 8.8. (TCO 6) The general syntax to overload the assignment operator (=) for a class is ____.(Points : 4) friend className& operator=(const className&);
className& operator=(className&);
string className& operator=(className&);
const className& operator=(const className&); Question 9.9. (TCO 6) What is the difference between a friend function and a member function of the class? (Points : 4) A friend function is a nonmember function of the class, whereas a member function is a member of the class.
All the member functions of a class are also friend functions.
The prototype for a friend function is not included in the class definition.
The definition of a friend function must be preceded by the class name and the scope resolution operator. Question 10.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 the constructors, and it must then deallocate all of the allocated memory in the destructor. Question 11.11. (TCO 6) Which of the following function prototypes overloads the != operator for the class rectangleType? (Points : 4) bool operator!=(rectangle&) const;
bool operator!=(const rectangleType&) const;
int operator!=(const rectangleType) const;
int operator!=(rectangle&) const; Question 12.12. (TCO 7) Virtual functions are first declared in what class? (Points : 4) The base class
The derived class
Both the base and the derived classes
Neither the base nor the derived class Question 1.1. (TCO 4) The ability to create a new class that receives some of its data and function members from a previously defined class is called _____. (Points : 4) Inheritance
Encapsulation
Polymorphism
Composition
Explanation / Answer
1. inheritance
2. cannot directly initialize public members that are inherited from the base class
3. derived
4. 0xbff00a10
5. myFunction(&emp);
6. All of the above
7.
8. string className& operator=(className&);
9. All the member functions of a class are also friend functions.
10. It must include the dynamic allocation in all the constructors, and it must then deallocate all of the allocated memory in the destructor.
11. bool operator!=(rectangle&) const;
12. The derived class
The address of a variable of the same typeRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.