MCQ Member Functions
MCQ Member Functions
1. In a class, member variables are often called its _________, and its member functions are
sometimes referred to as its behaviour, or ____________.
1. attributes, methods
2. none of these
3. values, morals
4. data, activities
5. attributes, activities
Answer: (a)
Answer: (e)
Answer: False
Answer: (b)
Answer: (b)
6. When the code of a member function is defined inside a class declaration, it is considered
as _________.
1. none of these
2. conditionally
3. inline
4. static
5. globally
Answer: (c)
7. If access specification is not given in the class definition, the default for members of a
class is:
1. public
2. private
3. extern
4. none of these
5. inline
Answer: (b)
Answer: (a)
Answer: (c)
Answer: (c)
11. To reference a member when using a pointer to object, use the ________
1. -> operator
2. & operator
3. dot operator
4. none of these
5. < > operator
Answer: (a)
12. True/False: In a class definition, all data members have to be declared before declaring
member functions.
Answer: False
13. You are not allowed to call a _______ method from anywhere other than method of the
same class.
1. global
2. private
3. local
4. none of these
5. public
Answer: (b)
14. True/False: A class having all data members and method members as private has no
practical use at all.
Answer: True
15. When we define a member function outside of the class definition, the definition starts
with a return type followed by:
1. none of these
2. class name, followed by the scope resolution operator
3. name of the first object
4. class name, followed by a semicolon
5. access specifier “private”
Answer: (b)
16. True/False: Only data members of a class are instantiated, member functions (methods)
are not instantiated.
Answer: True.
17. A class has one data member and one method member. This class is used in a program
that declares 10 objects of this class. The number of addresses for data member and
method member are, respectively:
1. 10 and 1
2. 10 and 10
3. 0 and 10
4. 10 and 0
Answer: (a)
18. It is possible to access a data member before declaring any object of that class, if that
member is declared as ________.
1. none of these
2. private
3. inline
4. static
5. public
Answer: (d)
19. True/False: A static data member of a class is not instantiated, it gets only one address. If
a program using this class declares 10 objects, all 10 objects have access to this single
address of the static member.
Answer: True
20. True/False: If we declare class X as friend of class Y, it implies that class Y is a friend of
class X.
Answer: False
Answer: (c)
22. The compiler makes available ________ as a special built-in pointer pointing to the
object.
1. &constructor pointer
2. this pointer
3. none of these
4. ~destructor *ptr
5. overloaded -> operator
Answer: (b)
23. True/False: A non-static method is not allowed to access a static member variable.
Answer: False
24. True/False: Normally, a friend function has one or more objects as parameters.
Answer: True
Answer: (b)
26. True/False: Members of a class specified as private are accessible only to the methods of
the class.
Answer: False
Find answers on the fly, or master something new. Subscribe today. See pricing options.