Sail E0 Webinar

MCQs

Total Questions : 30 | Page 3 of 3 pages
Question 21. Which is used to create a pure virtual function ?
  1.    $
  2.    =0
  3.    &
  4.    !
 Discuss Question
Answer: Option B. -> =0


For making a method as pure virtual function, We have to append '=0' to the class or method.


Question 22. What is meant by pure virtual function?
  1.    Function which does not have definition of its own.
  2.    Function which does have definition of its own.
  3.    Function which does not have any return type.
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Function which does not have definition of its own.


As the name itself implies, it have to depend on other class only.


Question 23. Pick out the correct option.
  1.    We cannot make an instance of an abstract base class
  2.    We can make an instance of an abstract base class
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> We cannot make an instance of an abstract base class


We cannot make an instance of an abstract base class


Question 24. Which is also called as abstract class?
  1.    virtual function
  2.    pure virtual function
  3.    derived class
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> pure virtual function


Classes that contain at least one pure virtual function are called as abstract base classes.


Question 25. Where does the abstract class is used?
  1.    base class only
  2.    derived class
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> base class only


base class only


Question 26. Where is the derived class is derived from?
  1.    derived
  2.    base
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> base


Because derived inherits functions and variables from base.


Question 27. Which operator is used to declare the destructor?
  1.    #
  2.    ~
  3.    @
  4.    $
 Discuss Question
Answer: Option B. -> ~


~


Question 28. Which of the following can derived class inherit?
  1.    members
  2.    functions
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> both a & b


both a & b


Question 29. Which constructor will initialize the base class data member?
  1.    derived class
  2.    base class
  3.    class
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> base class


Because it is having the proper data set to initialize, Otherwise it will throw a error.


Question 30. Pick out the correct statement.
  1.    A derived class's constructor cannot explicitly invokes its base class's constructor.
  2.    A derived class's destructor cannot invoke its base class's destructor.
  3.    A derived class's destructor can invoke its base class's destructor.
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> A derived class's destructor cannot invoke its base class's destructor.


Destructors are automatically invoked when a object goes out of scope or when a dynamically allocated object is deleted. Inheritance does not change this behavior. This is the reason a derived destructor cannot invoke its base class destructor.


Latest Videos

Latest Test Papers