Quiz
ch12
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (19)
1Select the false statement regarding inheritance.
- ASome derived classes can have multiple base classes.
- BBase classes are usually more specific than derived classes.
- CA derived class can be the base class for other derived classes.
- DA derived class can contain more attributes and behaviors than its base class.
2Which of the following is not a kind of inheritance in C++?
- Aprotected.
- Bstatic.
- Cprivate.
- Dpublic.
3The is-a relationship represents.
- AInformation Hiding.
- BA friend.
- CComposition.
- DInheritance.
4 Which of the following is most likely a base class of the other three?
- Aautomobile.
- BminiVan.
- Cconvertible.
- Dsedan.
5Which of the following is not a good example of a hierarchy that could be modeled by inheritance?
- AAirplanes.
- BGeometric shapes.
- CPrime numbers.
- DAnimals.
6To declare class subClass a privately derived class of superClass one would write:
- Aclass subclass : private superClass.
- Bclass subclass < private superClass >.
- Cclass subclass inherits private superClass.
- Dclass subclass :: private superClass.
7From most restrictive to least restrictive, the access modifiers are:
- Aprotected, public, private.
- Bprotected, private, public
- Cprivate, public, protected.
- Dprivate, protected, public.
8Protected base class members cannot be accessed by:
- Afriends of derived classes.
- BFunctions that are not derived-class member functions.
- CFunctions that are neither friends of the base class, derived-class member functions nor friends of a derived class
- Dfriends of the base class.
9Assuming the definition,
class Circle : public Point
which of the following is false?- AThe keyword public indicates the type of inheritance.
- BAll the public and protected members of class Circle are inherited as public and protected members, respectively, into class Point.
- CThe colon ( : ) in the header of the class definition indicates inheritance.
- DPoint is the base class and Circle is the derived class.
10Assuming the following is the beginning of the constructor definition for class Circle which inherits from class Point,
Circle::Circle( double r, int a, int b )
: Point( a, b )
The second line:- AInvokes the Point constructor with values a and b.
- BIs unnecessary because the Point constructor is called automatically.
- CCauses a compiler error.
- DIndicates inheritance.
11Which of the following is not one of the disadvantages of using the “copy-and-paste” approach to duplicating code from one class into another class?
- AErrors are prone to getting spread around.
- BAll of the above are disadvantages of the “copy-and-paste” approach.
- CIt is time consuming.
- DIt forces the system to store many physical copies of the code, creating a code-maintenance nightmare.
12When should base class members be declared protected?
- AThe protected access specified should never be used.
- BWhen these members should be available only to derived classes (and friends), not to other clients.
- CWhen all clients should be able to access these members.
- DWhen these members are only used by member functions of this base class.
13When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.
- ABase class, derived class.
- BBase class, base class.
- CDerived class, base class.
- DDerived class, public.
14Base class constructors and assignment operators:
- ACan be inherited by derived classes, but generally are not.
- BAre not inherited by derived classes.
- CShould not be called by derived class constructors and assignment operators.
- DCan call derived-class constructors and assignment operators.
15Suppose class A inherits from base class B. What is the order in which their constructors and destructors will be called when an object of class A is instantiated and then destroyed?
- AB constructor, A constructor, A destructor, B destructor.
- BA constructor, B constructor, A destructor, B destructor.
- CB constructor, A constructor, B destructor, A destructor.
- DA constructor, B constructor, B destructor, A destructor.
16Which forms of inheritance are is-a relationships?
- AOnly public and private.
- BOnly public.
- CAll forms of inheritance are is-a relationships.
- DOnly public and protected.
17When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?
- Apublic, private
- Bpublic, protected.
- Cprotected, private
- Dprotected, protected.
18Theoretically, clients do not need to see the _________ of classes from which they derive other classes.
- AInterface.
- BHeader files.
- CSource code.
- DObject code.
19Which of the following is true about using inheritance in software engineering?
- AA class produced through inheritance should be as large as possible to fully encompass all of the functionality it should offer.
- BCommon attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit.
- CThe standard C++ libraries that are shipped with C++ compilers are usually enough to accomplish anything an application might need to do.
- DIt is best to create a huge class library to make it easy for a client to find the most appropriate class for his or her needs.
Information
- Description
- Quiz on ch12, created by mnahvi7+examtime on 14/04/2016.
- Author
- mnahvi7+examtime
- Language
- English
- Views
- 2
- Rating
- No ratings yet Rate this quiz