What happens when we try to compile the class definition in following code snippet?
class Birds {};
class Peacock : protected Birds {};
A. It will not compile because class body of Birds is not defined.
B. It will not compile because class body of Eagle is not defined.
C. It will not compile because a class cannot be protectedly inherited from other class.
D. It will compile succesfully. (ANS)
Which of the following statements is incorrect?
A. Friend keyword can be used in the class to allow access to another class.
B. Friend keyword can be used for a function in the public section of a class.
C. Friend keyword can be used for a function in the private section of a class.
D. Friend keyword can be used on main(). (ANS)
Which of the following statement is correct regarding destructor of base class?
A. Destructor of base class should always be static.
B. Destructor of base class should always be virtual. (ANS)
C. Destructor of base class should not be virtual.
D. Destructor of base class should always be private.
Which of the following statements is correct when a class is inherited publicly?
A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class. (ANS)
Which of the following statements about virtual base classes is correct?
A. It is used to provide multiple inheritance.
B. It is used to avoid multiple copies of base class in derived class. (ANS)
C. It is used to allow multiple copies of base class in a derived class.
D. It allows private members of the base class to be inherited in the derived class.
Which of the following can be overloaded?
A. Object
B. Functions
C. Operators
D. Both B and C (ANS)
class Birds {};
class Peacock : protected Birds {};
A. It will not compile because class body of Birds is not defined.
B. It will not compile because class body of Eagle is not defined.
C. It will not compile because a class cannot be protectedly inherited from other class.
D. It will compile succesfully. (ANS)
Which of the following statements is incorrect?
A. Friend keyword can be used in the class to allow access to another class.
B. Friend keyword can be used for a function in the public section of a class.
C. Friend keyword can be used for a function in the private section of a class.
D. Friend keyword can be used on main(). (ANS)
Which of the following statement is correct regarding destructor of base class?
A. Destructor of base class should always be static.
B. Destructor of base class should always be virtual. (ANS)
C. Destructor of base class should not be virtual.
D. Destructor of base class should always be private.
Which of the following statements is correct when a class is inherited publicly?
A. Public members of the base class become protected members of derived class.
B. Public members of the base class become private members of derived class.
C. Private members of the base class become protected members of derived class.
D. Public members of the base class become public members of derived class. (ANS)
Which of the following statements about virtual base classes is correct?
A. It is used to provide multiple inheritance.
B. It is used to avoid multiple copies of base class in derived class. (ANS)
C. It is used to allow multiple copies of base class in a derived class.
D. It allows private members of the base class to be inherited in the derived class.
Which of the following can be overloaded?
A. Object
B. Functions
C. Operators
D. Both B and C (ANS)
No comments:
Post a Comment