Sail E0 Webinar

MCQs

Total Questions : 23 | Page 3 of 3 pages
Question 21.

Which of the following statements is incorrect?


  1.    Friend keyword can be used in the class to allow access to another class.
  2.    Friend keyword can be used for a function in the public section of a class.
  3.    Friend keyword can be used for a function in the private section of a class.
  4.    Friend keyword can be used on main().
 Discuss Question
Answer: Option D. -> Friend keyword can be used on main().


Question 22.

Which of the following statement is correct regarding destructor of base class?


  1.    Destructor of base class should always be static.
  2.    Destructor of base class should always be virtual.
  3.    Destructor of base class should not be virtual.
  4.    Destructor of base class should always be private.
 Discuss Question
Answer: Option B. -> Destructor of base class should always be virtual.


Question 23.


What happens when we try to compile the class definition in following code snippet?


class Birds {};
class Peacock : protected Birds {};
  1.    It will not compile because class body of Birds is not defined.
  2.    It will not compile because class body of Peacock is not defined.
  3.    It will not compile because a class cannot be protectedly inherited from other class.
  4.    It will compile succesfully.
 Discuss Question
Answer: Option D. -> It will compile succesfully.


Latest Videos

Latest Test Papers