Object Oriented Programming in C++ MCQ with Answers

26. The class istream is derived from —- which contains all the necessary functions for handling input
a. Base class
b. ios class
c. derived class
d. both a and c
Answer: (b)

27. The class fstream inherited from both iostream and fstreambase is used for files that will perform —-
a. only output
b.only input
c. both input and output
d.none of them
Answer: (c)

28. The function —– will return the last read character and will move the inside pointer, one with -1 char.
a) getline()
b) flush()
c) peek()
d) putback()
Answer: (d)

29. —- is an identifier that can be inserted into an output stream or extracted from an input stream in order to produce the desired effect.
a)Stream
b) Manipulator
c) this
d) Flag
Answer: (b)

30. A class generated from a class template is called —-
a) Inherited class
b) derived class
c) generated class
d) base class
Answer: (c)

31. When the compiler generates a class, function, or static data member from a template, it is referred to as —-
a. template instantiation
b. template specialization
c. partial specialization
d. function specialization
Answer: (a)

32. What are the two basic models in the exception handling theory?
a. caught and uncaught
b. termination and resumption
c. try and block
d. none of these
Answer: (b)

33. which of these is/are the exception classes derived from logic_error
i) domain_error ii) out_of_range iii) bad_cast iv) bad_alloc
a. i),ii),iii) only
b. iv) only
c. i) and iv) only
d. iii) only
Answer: (a)

34. Stack is an example of —– structure.
a. SISO
b. FIFO
c. LIFO
d. LILO
Answer: (c)

35. The standard sequence containers include —-
i) vector ii) deque iii) list iv) stack
a. and ii) only
b. i), ii) and iii)
c. and iv) only
d. i),ii),iii) and iv)
Answer: (b)

36. The —- diagram shows the change of an object through time.
a. Activity
b. Collaboration
c. Use case
d. State
Answer: (d)

37. Which of these links is used to avoid the repetition of scenarios in multiple use cases.
a. Include
b. Generalization
c. Extends
d. None of these
Answer: (a)

38. —– is a mechanism of reusing and extending existing classes without modifying them, thus producing hierarchical relationships between them.
a. Static Binding
b. Dynamic Binding
c. Inheritance
d. Virtual class
Answer: (c)

39. —– allows you to create a derived class that inherits properties from more than one base class.
a. Multilevel inheritance
b. Multiple inheritances
c. Hybrid Inheritance
d. Hierarchical Inheritance
Answer: (b)

40. —- pointers are not modifiable.
a. that
b. this
c. indirection
d. address
Answer: (b)

41. The —– and —- statements which we were using for input from keyboard and output to display screen C++.
a. Cin, cout
b. scanf, printf
c.system.out.println, printwriter
d. cin, scanf
Answer: (a)

42. The destructor is used for
a. initializing of variables
b. deallocation of memory
c. construction of variable
d. all of the above
Answer: (b)

43. #include<iostream.h>
#include<iomanip.h>
const int size=10;
void main()
{
Char str[size];
Cout<<”enter a string”;
Cin>>setw(size)>>str;
}
for the above program, maximum how many characters can be stored in the array.

a. 11 character
b. 10 character
c. 9 character
d. 8 character
Answer: (c)

44. Every function can have —- or —– arguments
a. no, only one
b. one, maximum two
c.one, any number of
d. no, any number of
Answer: (d)

45. When the object of any class, obj is created, automatically the constructor is —- and data is initialized to —–.
a. Invoked, one
b. Invoked, zero
c.declare, default
d. declare, one
Answer: (b)

46. Operator overloading provides a flexible way to work with —– and can make —- look obvious
a. object, object
b. simple varriables, program code
c. Classes, program code
d. classes, assembly code
Answer: (c)

47. The functions of the derived class can access —- members of the base class but not the —- members of the base class.
a. public and protected, private
b. private and protected, public
c. private, protected
d. private, public and protected
Answer: (a)

48. A pure virtual function is an example of —–which does not have —-.
a run time polymorphism, any function to operate.
b. polymorphism, any function to operate
c. run time polymorphism, anybody
d. class, anybody
Answer: (c)

49. Data in the program was created by —- and if more than one function had to access data, —– were used
a. variables, local variable
b. Variables, global variables
c.program name, automatic variable
d. variable, register variable
Answer: (b)

50. which of these file open modes do you use to write into the file.
a. ios ::ate
b. ios ::in
c. ios::out
d. ios ::app
Answer: (c)

51. The current reading position, which is the index of the next byte that will be read from the file is called —–.
a. get pointer
b. set pointer
c. curr pointer
d. put pointer
Answer: (a)

52. To perform identical operations for each type of data compactly and conveniently, we use —–
a. Inline function
b. function templates
c. this pointer
d. friend function
Answer: (b)

53. A static data member-generated from a static data member template is called —– static data member
a. inherited
b. base
c. generated
d. derived
Answer: (c)

54. Exceptions should not be used for —-
a. asynchronous events
b. ordinary error condition
c. flow of control
d. all of the above
Answer: (a)

55. —- is the exception class derived from runtime_error.
a. range_error
b. lengh_error
c. bad_typeid
d. met_error
Answer: (a)

56. From the following list identify iterator adaptors.
a. reverse iterator
b. insert iterator
c. raw storage iterator
d. all of these
Answer: (d)

57. When you wish to show the sequence of events on a broader scale, use —-
a. activity diagram
b. state diagram
c. both A) and B)
d. either A) or B)
Answer: (c)

58. State true or false
i) Attributes that are static only exist once for all instances of the class.
ii) If an attribute is declared final, its value can be changed.
a. true, false
b. true, true
c. false, false
d. false, true
Answer: (a)

Conclusion

This article has provided a comprehensive overview of Object Oriented Programming in C and presented multiple-choice questions with their answers for readers to test their knowledge. By understanding the fundamental concepts and principles of OOP in C, programmers can enhance their ability to design and develop efficient and scalable applications.

It is crucial to grasp the significance of encapsulation, inheritance, polymorphism, and abstraction in OOP as they play a pivotal role in creating modular and reusable code. As you continue your journey in programming, make sure to practice implementing OOP concepts in real-world scenarios to hone your skills further. Keep learning and exploring new possibilities with Object Oriented Programming!

Thanks for visiting our website, if you like the post on Object Oriented Programming in C++ MCQ with Answers, please share it on social media.

Read More :

Share on Social Media

15 thoughts on “Object Oriented Programming in C++ MCQ with Answers”

  1. At number 7.
    Arrays are non primitive data types but you posted it as primitive data types….kindly correct it.

  2. What is true about Destructor?

    a) No need to write calling statement.

    b) It is automatically called before program c) Both a & b

    terminates.

    d) None of the Above

  3. Ansari garhan

    Woe meri help ke liye 😊 🫂 🙏 😊 🫂 🙏 😊 🫂 🙏 😊 🫂 🙏 😊 🫂 🙏 😊

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top