Sail E0 Webinar

MCQs

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

Which of the following statements are correct for a static member function?

       1. It can access only other static members of its class.

       2. It can be called using the class name, instead of objects.


  1.    Only 1 is correct.
  2.    Only 2 is correct.
  3.    Both 1 and 2 are correct.
  4.    Both 1 and 2 are incorrect.
 Discuss Question
Answer: Option C. -> Both 1 and 2 are correct.


Question 2.

Which of the following is the only technical difference between structures and classes in C++?


  1.    Member function and data are by default protected in structures but private in classes.
  2.    Member function and data are by default private in structures but public in classes.
  3.    Member function and data are by default public in structures but private in classes.
  4.    Member function and data are by default public in structures but protected in classes.
 Discuss Question
Answer: Option C. -> Member function and data are by default public in structures but private in classes.


Question 3.

Which of the following means "The use of an object of one class in definition of another class"?


  1.    Encapsulation
  2.    Inheritance
  3.    Composition
  4.    Abstraction
 Discuss Question
Answer: Option C. -> Composition


Question 4.

Which of the following can be overloaded?


  1.    Object
  2.    Functions
  3.    Operators
  4.    Both B and C
 Discuss Question
Answer: Option D. -> Both B and C


Question 5.

Which of the following statements is correct?


  1.    Data items in a class must be private.
  2.    Both data and functions can be either private or public.
  3.    Member functions of a class must be private.
  4.    Constructor of a class cannot be private.
 Discuss Question
Answer: Option B. -> Both data and functions can be either private or public.


Question 6.

How many objects can be created from an abstract class?


  1.    Zero
  2.    One
  3.    Two
  4.    As many as we want
 Discuss Question
Answer: Option A. -> Zero


Question 7.

Constructor is executed when _____.


  1.    an object is created
  2.    an object is used
  3.    a class is declared
  4.    an object goes out of scope.
 Discuss Question
Answer: Option A. -> an object is created


Question 8.


What does the class definitions in following code represent?


class Bike
{
Engine objEng;
};
class Engine
{
float CC;
};
  1.    kind of relationship
  2.    has a relationship
  3.    Inheritance
  4.    Both A and B
 Discuss Question
Answer: Option B. -> has a relationship


Question 9.

Which of the following statements about virtual base classes is correct?


  1.    It is used to provide multiple inheritance.
  2.    It is used to avoid multiple copies of base class in derived class.
  3.    It is used to allow multiple copies of base class in a derived class.
  4.    It allows private members of the base class to be inherited in the derived class.
 Discuss Question
Answer: Option B. -> It is used to avoid multiple copies of base class in derived class.


Question 10.

Which of the following statements is correct when a class is inherited privately?


  1.    Public members of the base class become protected members of derived class.
  2.    Public members of the base class become private members of derived class.
  3.    Private members of the base class become private members of derived class.
  4.    Public members of the base class become public members of derived class.
 Discuss Question
Answer: Option B. -> Public members of the base class become private members of derived class.


Latest Videos

Latest Test Papers