MCQ S
MCQ S
MCQ S
A) base, derived
B) derived, base
C) derived, initial
D) base, final
2. A derived class with only one base class is called …………… inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical
3. A class can inherit properties from more than one class which is known as
……….inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical
4. A class can be derived from another derived class which is known as ……….
inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical
5. When the properties of one class are inherited by more than one class, which is
called ……… inheritance.
A) single
B) multiple
C) multilevel
D) hierarchical
7. When a base class is privately inherited by derived class public members of the
base class can only be accessed by the ……… of the derived class.
A) non-member functions
B) friend functions
C) member functions
D) class members
9. State whether the following statements about inheritance are True or False.
i) A public member of a class can be accessed by its own objects using the dot
operator.
ii) While inheriting, the private members of the base class will never become
members of its derived class.
A) True, False
B) False, True
C) True, True
D) False, False
10. A member declared as ………….. is accessible by the member functions within its
class and any class immediately derived from it.
A) protected
B) private
C) public
D) friend
11. When the base class is publicly inherited, public members of the base class
become …………. of the derived class.
A) private members
B) protected members
C) Public members
D) Not inherited
12. In the protected derivation, both the public and protected members of the base
class become …………. members of the derived class.
A) protected
B) private
C) public
D) friend
13. What will be the order of execution of base class constructors in the following
method of inheritance?
class A: public B, public C {….};
A) B(); C(); A();
B) C(); B(); A();
C) A(); B(); C();
D) B(); A(); C();
14. What will be the order of execution of base class constructors in the following
method of inheritance?
class A: public B, virtual public C {….};
A) B(); C(); A();
B) C(); B(); A();
C) A(); B(); C();
D) B(); A(); C();
15. While the friend functions and the member functions of a friend class can have
direct access to both the private and protected data, the member functions of a
derived class can directly access only the ………… data.
A) protected
B) private
C) public
D) friend
17. In ……………….. inheritance, the base classes are constructed in the order in which
they appear in the deceleration of the derived class.
A) multipath
B) multiple
C) multilevel
D) hierarchical
19. The member functions of a derived class can directly access only the ………………..
data.
A) private and protected
B) private and public
C) protected and public
D) private, protected and public
20. The friend functions and the member functions of a friend class can directly
access the ………………. data.
A) private and protected
B) private and public
C) protected and public
D) private, protected and public
Answers
1. B) derived, base
2. A) single
3. B) multiple
4. C) multilevel
5. D) hierarchical
6. A) private members
7. C) member functions
8. A) protected
9. C) True, True
10. A) protected
11. C) Public members
12. A) protected
13. A) B(); C(); A();
14. B) C(); B(); A();
15. A) protected
16. C) multilevel
17. B) multiple
18. A) multipath
19. C) protected and public
20. A) private and protected
Here are the collections of MCQ questions on C++ classes and objects includes MCQ
questions about different ways of specifying a class and creating objects, defining
and nesting of member function, private, static and constant member function. It
also includes static data members and methods of using objects as function
arguments.
1. In C++, the declaration of functions and variables are collectively called …….
A) class members
B) function members
C) object members
D) member variables
2. The keywords private and public used in C++ are known as ………….
A) keyword labels
B) visibility labels
C) declaration labels
D) display labels
3. The variables declared inside the class are known as data members and functions
are known as ………….
A) data functions
B) inline functions
C) member functions
D) member variables
4. Only the …………………. can have access to private members and private functions.
A) data functions
B) inline functions
C) member functions
D) member variables
5. The binding of data and functions together into a single class-type variable is
referred to as …………..
A) encapsulation
B)
C)
D)
6. Which of the following statements about member functions are True or False.
i) A member function can call another member function directly with using the dot
operator.
ii) A member function can access the private data of the class.
A) i-True, ii-True
B) i-False, ii-True
C) i-True, ii-False
D) i-True, ii-True
8. A member function can be called by using its name inside another function of the
same class, which is known as ………… of the member function.
A) sub-function
B) sub-member
C) nesting
D) sibling
9. A ………………. member function can only be called by another function that is member
of its class.
A) friend
B) static
C) public
D) private
10. ……………….. member variable is initialized to zero when the first object of its
class is created where no other initialization is permitted.
A) friend
B) static
C) public
D) private
11. State whether the following statements are True or False about the
characteristics of static data members.
i) Only one copy of a static member is created for the entire class and is shared
by all the objects of that class, no matter how many objects are created.
ii) The static member variable is visible only within the class, but its lifetime
is the entire program.
A) i-True, ii-True
B) i-False, ii-True
C) i-True, ii-False
D) i-True, ii-True
12. Static variables are associated with the class itself rather than with any
class object, they are also known as …………….
A) class variables
B) object variables
C) function variables
D) internal variables
13. Static variables are like ………………… as they are declared in a class declaration
and defined in the source file.
A) inline member function
B) non-inline member function
C) static member function
D) dynamic member function
14. A …………….. can have access to only other static members declared in the same
class.
A) constant member function
B) private member function
C) static member function
D) friend function
15. A static member function can be called using the ………………… instead of its
objects.
A) variable name
B) function name
C) Class name
D) object name
16. While using an object as a function argument, a copy of the entire object is
passed to the function in ………….. method.
A) pass-by-value
B) pass-by-reference
C) pass-by-variable
D) pass-by-function
17. A ……………………., although not a member function, has full access rights to the
private members of the class.
A) constant member function
B) private member function
C) static member function
D) friend function
18. ……………. can be invoked like a normal function without the help of any object.
A) constant member function
B) private member function
C) static member function
D) friend function
19. A ………….. can only be called by another function that is a member of its class.
A) constant member function
B) private member function
C) static member function
D) friend function
20. If a member function does not alter any data in the class, that may be declared
as ………………..
A) constant member function
B) private member function
C) static member function
D) friend function
Answers
1. A) class members
2. B) visibility labels
3. C) member functions
4. C) member functions
5. A) encapsulation
6. B) i-False, ii-True
7. B) inline function
8. C) nesting
9. D) private
10. B) static
11. A) i-True, ii-True
12. A) class variables
13. B) non-inline member function
14. C) static member function
15. C) Class name
16. A) pass-by-value
17. D) friend function
18. D) friend function
19. B) private member function
20. A) constant member function