Quiz: Classes & Objects

To View Tricks: Login Required

Number of Questions: 25

Question: 1 -

Which of these following members are not accessed by using direct member access operator?

Options:
  1. Public

  2. Protected

  3. Both B & C

  4. Private

  5. Answer:

    Both B & C

    Solution:

    Because of the access is given to the private and protected, We can’t access them by using direct member access operator.


Question: 2 -

Which other keywords are also used to declare the class other than class?

Options:
  1. Struct

  2. Both struct & union

  3. Union

  4. Object

  5. Answer:

    Both struct & union

    Solution:

    Struct and union take the same definition of class but differs in the access techniques.


Question: 3 -

How can we make a class abstract?

Options:
  1. By making at least one member function as pure virtual function.

  2. By declaring it abstract using the static keyword.

  3. By making all member functions constant

  4. By declaring it abstract using the virtual keyword.

  5. Answer:

    By making at least one member function as pure virtual function.

    Solution:

     We can make a class abstract by making at least one member function as pure virtual function.


Question: 4 -

Which of the following is not correct for virtual function in C++ ?

Options:
  1. Virtual function is defined in base class

  2. Virtual function can be static.

  3. Must be declared in public section of class

  4. Virtual function should be accessed using pointers

  5. Answer:

    Virtual function can be static.

    Solution:

    Virtual function is can’t be static in C++.


Question: 5 -

How many specifiers are present in access specifiers in class?

Options:
  1. 1

  2. 4

  3. 3

  4. 2

  5. Answer:

    3

    Solution:

    There are three types of access specifiers. They are public, protected and private.