Exam 14: Inheritance
Exam 1: C++ Basics37 Questions
Exam 2: Flow of Control33 Questions
Exam 3: Function Basics30 Questions
Exam 4: Parameters and Overloading31 Questions
Exam 5: Arrays32 Questions
Exam 6: Structures and Classes37 Questions
Exam 7: Constructors and Other Tools32 Questions
Exam 8: Operator Overloading,friends,and References31 Questions
Exam 9: Strings37 Questions
Exam 10: Pointers and Dynamic Arrays29 Questions
Exam 11: Separate Compilation and Namespaces35 Questions
Exam 12: Streams and File IO43 Questions
Exam 13: Recursion40 Questions
Exam 14: Inheritance30 Questions
Exam 15: Polymorphism and Virtual Functions34 Questions
Exam 16: Templates27 Questions
Exam 17: Linked Data Structures30 Questions
Exam 18: Exception Handling29 Questions
Exam 19: Standard Template Library46 Questions
Exam 20: Patterns and Uml22 Questions
Select questions type
What are the benefits of inheritance and Object Oriented Programming?
Free
(Essay)
4.8/5
(37)
Correct Answer:
The benefits are abstraction and code reuse: A general form of a class can be defined.It contains common features of the several specialized versions that may be defined and caused to inherit from the general form.This saves you the trouble of writing identical code two or more times.
Though the text does not say this explicitly,inheritance and OOP better enable modeling of problems within programs.The objects represent actors and the member functions represent behavior of the actors.The data members are information the actors must remember to carry out their prescribed behavior.
A base/member initialization list is preceded by
Free
(Multiple Choice)
4.8/5
(33)
Correct Answer:
C
If B is a public base class of D,then D's members cannot invoke public members functions of B.
Free
(True/False)
4.9/5
(39)
Correct Answer:
False
A programmer can use inheritance with an existing library for which only the header file and binary are available,to derive a class more suitable to her purpose.
(True/False)
4.8/5
(43)
If class D is derived from class B then class D has only some of the members from B,and the additional members defined in D.
(True/False)
4.8/5
(32)
Given the class below,tell to what value the default constructor initializes the data member.Name this initialization technique and give another way to write the constructor.
class A
{
public:
A();
private:
int a;
};
A::A(): a(17)
{
//deliberately empty
}
(Essay)
4.9/5
(34)
Constructors are inherited.After all something has to initialize the inherited variables.
(True/False)
4.9/5
(37)
When a derived class inherits from a base class,how is the base class constructor called?
(Essay)
4.9/5
(40)
Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.When we destroy an object of class Child,three destructors are called: i)Child,ii)Parent,iii )GrandParent..What is the order?
(Multiple Choice)
4.9/5
(43)
If a base class constructor is not called explicitly in the definition of a derived class constructor,an error results.
(True/False)
4.9/5
(42)
If a class B is a pubic base class for a derived class D,then an object of class D bears what relationship to class B?
(Multiple Choice)
4.7/5
(33)
Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.When we declare an object of class Child,three constructors are called: i)Child,ii)Parent,iii )GrandParent..What is the order?
(Multiple Choice)
4.7/5
(38)
If B is a base class of D,then D's members cannot access the private data members of B without regard to the kind of inheritance.
(True/False)
4.8/5
(34)
If B is a base class of D,then D's members cannot invoke private member functions of B without regard to the kind of inheritance.
(True/False)
4.8/5
(37)
In the code for HourlyEmployee that is derived from Employee,the constructor code appears
HourlyEmployee::
HourlyEmployee(string theName,
string theNumber,
double theWageRate,
double theHours
)
: Employee(theName,theNumber),
wageRate(theWageRate),
hours(theHours)
{
// deliberately empty
}
Describe the purpose of the items after the colon (:)in this code.
(Essay)
4.8/5
(43)
When class D is derived from class B,the derived class is usually smaller.Explain.
(True/False)
4.8/5
(35)
Neither the assignment operator overloading nor the copy constructor is inherited.If you do not create one,does this mean that the derived class will have no assignment operator or copy constructor?
(Essay)
4.9/5
(36)
Showing 1 - 20 of 30
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)