Programming MCQs

MCQ Questions On C++ Programming With Answer Set-2

Pinterest LinkedIn Tumblr

Here are the collections of top 20 MCQ questions on C++ programming includes MCQ questions on C++ operators, functions, and their types along with their characteristics, classes and objects, constructors and distructors used in C++. It also includes operator overloading, encapsulation, inheritance and polymorphism.

1. The ……………. Operator is known as an insertion operator.
A) >>
B) >
C) <<
D) <

2. State True or False.
i) A static function can have access to only other static members (functions or variables) declared in the same class.
ii) A static member function can be called using the class name (instead of its objects)
A) True, True
B) True, False
C) False, True
D) False, False

3. Which of the following condition is true for an object used as a function argument?
i) A copy of the entire object is passed to the function.
ii) Only the address of the object is transferred to the function.
A) Only i
B) Only ii
C) Both i and ii
D) None of them

4. …………… enable us to hide, inside the object, both the data fields and the methods that act on that data.
A) Encapsulation
B) Polymorphism
C) Inheritance
D) Overloading

5. Which of the following is/ are the characteristics of friend function.
A) It is not in the scope of the class to which it has been declared as a friend.
B) It can invoke a normal function without the help of any object.
C) Usually, it has objects as arguments.
D) All of the above.

6. The dereferencing operator ………….. is used to access a member when we use pointers to both the object and the member.
A) ->*
B) .*
C) Any of the above
D) None of the above

7. A ………………. Is a class whose instances themselves are classes.
A) Subclass
B) Abstract Class
C) MetaClass
D) Object Class

8. The dereferencing operator ……… is used when the object itself has used width in the member pointer.
A) ->*
B) .*
C) Any of the above
D) None of the above

9. A constructor that accepts no parameters is called the ……………….
A) Paramless constructor
B) No parameter constructor
C) Default constructor
D) Argumentless constructor

10. Automatic initialization of an object is carried out using a special member function called …………
A) Friend
B) Casting
C) Reference Parameter
D) Constructor

Read Also: Solved MCQ Questions on C++ Programming set-4

11. Which of the following characteristics of the constructor are true.
i) They should be declared in the public section.
ii) They are invoked automatically when the objects are created.
iii) They do not have return types and void also.
iv) We cannot refer to their address.
v) Constructors cannot virtual.
A) Only i, ii, iii and v
B) Only ii, iii, iv, and v
C) Only i, iii, iv and v
D) All i, ii, iii, iv and v

12. A ……………. takes a reference to an object of the same class as itself as an argument.
A) Reference constructor
B) Copy Constructor
C) Self Constructor
D) None of the above

13. State True or False
i) A destructor never takes any argument nor does it return any value.
ii) It releases memory space for future use.
A) True, True
B) True, False
C) False, True
D) False, False

14. Which of the following operates cannot be overloaded?
i) Size of operator (sizeof)           ii) Scope resolution Operator
iii) Conditional operator (?:)        iv) Assignment Operator (=)
A) i, ii, iii only
B) ii, iii, iv only
C) i, iii, iv only
D) all i, ii, iii, iv

15. …………. Is the process of creating new classes, called derived classes from existing classes called a base class.
A) Inheritance
B) Encapsulation
C) Polymorphism
D) Overloading

16. State True or False.
i) While overloading operators new operators can be overloaded.
ii) The binary operator such as +, -, * and must explicitly return a value.
A) True, True
B) True, False
C) False, True
D) False, False

17. ………… function writes a string of text to a window.
A) cputs ()
B) put ()
C) gets ()
D) tputs ()

18. Which of the following condition (s) should satisfy the casting operator.
i) It must be a class member.
ii) It must not satisfy a return type.
iii) It must have any arguments.
iv) All of the above.

19. Find the Hierarchy of Data Types.
i) Long double       ii) Double       iii) Float     iv) Long     v) Int      vi) Char
A) 1-2-3-4-5-6
B) 1-3-2-4-5-6
C) 1-2-3-5-4-6
D) 1-2-4-3-5-6

20. ………….. function sets the fill pattern and color.
A) floodfill ()
B) setcolor()
C) setfillstyle()
D) fillstyle ()

Answers:

1. C) <<
2. B) True, False
3. C) Both i and ii
4. A) Encapsulation
5. D) All of the above.
6. A) ->*
7. C) MetaClass
8. B) .*
9. C) Default constructor
10. D) Constructor
11. D) All i, ii, iii, iv and v
12. B) Copy Constructor
13. A) True, True
14. A) i, ii, iii only
15. A) Inheritance
16. C) False, True
17. A) cputs ()
18. iv) All of the above.
19. A) 1-2-3-4-5-6
20. C) setfillstyle()

Read Next: MCQ Questions On C++ Programming With Answers Set-3
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.