MULTIPLE CHOICE QUESTIONS AND ANSWERS
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)
2. Which of these keywords are access specifiers?
1. near and far
2. opened and closed
3. table and row
4. none of these
5. private and public
Answer: (e)
3. True/False: An Object can be declared prior to the class definition.
Answer: False
4. Use of __________ protects data from inadvertent modifications.
1. protect() member function
2. private access specifier
3. class protection operator, @
4. none of these
5. public access specifier
Answer: (b)
5. A suitable place to store Class declarations is _______.
1. none of these
2. their own header files
3. Auxiliary .cpp file
4. main .cpp files, along with function definitions
5. floppy diskettes
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)
8. A class is a (n) _____________ that is defined by the programmer.
1. user-defined variable type
2. none of these
3. attribute
4. method
5. function
Answer: (a)
9. Member methods of a class object access other members using _______.
1. dot operator
2. stream insertion operator
3. none of these
4. extraction operator
5. arrow operator
Answer: (c)
10. If Rectangle is a class name, the declaration Rectangle *Ptr;
1. none of these
2. is illegal in C++
3. declares an object of class Rectangle
4. assigns the value of *Ptr to the object Rectangle
5. declares a variable called Ptr of type pointer to Rectangle
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
21. A static member function can access only.
1. none of these
2. inline functions
3. static Member
4. private member
5. public member
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
25. A global variable if declared static, its scope is ________
1. universal
2. file
3. only next function
4. only function main
5. none of these
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.