Programming MCQs

Top 20 MCQ Questions On C++ Classes And Objects

Pinterest LinkedIn Tumblr

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

7. When the function is defined inside a class, it is treated as ………………….
A) data function
B) inline function
C) member function
D) member variable

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

Read Next: Top 20 MCQ On Constructors And Destructors In C++
Read More: C and C++ MCQ Questions

Author

Shuseel Baral is a web programmer and the founder of InfoTechSite has over 8 years of experience in software development, internet, SEO, blogging and marketing digital products and services is passionate about exceeding your expectations.

Comments are closed.