Object Oriented Programming C MCQs
Object Oriented Programming C MCQs
2. One of the basic concepts in Object Oriented Programming approach is bundling both data and functions into
one unit known as ----.
a. Simple variable
b. object
c. bundle
d. both a and b
5. In the switch case statement, every case should have a ---- statement as the last statement
a. Jump
b. break
c. exit
d. both a and b
6. Conditional operator (?:) is a handy operator which acts as a shortcut for ----
a. if-else statement
b. switch statement
c. break statement
d. goto statement
1
9. Strings are nothing but ----- arrays
a. character
b. integer
c. floating point
d. both c and b
10. If there is no value returned by the function, then the function return type should be specified as -----
a. void
b. Function name only
c. int
d. float
12. More than one user-defined functions can have the same name and perform different operations. This is a
powerful feature of C++ and is known as ----
a. inheritance
b.operator loading
c. function overloading
d. both c and b
14. Private data and functions can be accessed only by the ---- of the class
a. Member data
b. member functions
c. friend function
d.both a and b
15. Constructors are member functions of a class that have the same name as the -----
a. class name name
b.data member
c. class name
d. other class data member
16. When using operator overloading, the operator should perform only the ----. Otherwise, it will lead to more
confusion.
a. most obvious function
b. Local function
c. global function
d. both b and c
2
17. Which of the following operator cannot be overload?
a. Addition
b. scope resolution operator
c. multiplication
d. division
19. The features of the base class are said to be inherited by the ----
a. constructor
b. Protected class
c. private class
d. derived class
21. Data members which will be inherited will have to be declared as -----
a. protected
b. public
c. private
d. both b and c
22. Multiple Inheritances is the process of inheriting a class from ----- class
a. single parent
b. more than one child
c. more than one parent
d. Only one child
23. For inheritance, parent class member functions are invoked using the ---- operator
a. Dot
b. scope resolution
c. colon
d.->
3
25. The header file---- is a header file containing the declarations of cin and cout classes
a. system.h
b. Stdio.h
c. iostream.h
d . process.h
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
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
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()
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
31. When the compiler generates a class, function or static data members from a template, it is referred to as ----
a. template instantiation
b. template specialization
c. partial specialization
d. function specialization
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
4
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
36. The ---- diagram shows the change of an object through time.
a. Activity
b. Collaboration
c. Use case
d. State
37. Which of these links is used to avoid repetition of scenarios in multiple use cases.
a. Include
b. Generalization
c. Extends
d. None of these
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
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
5
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
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
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
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
6
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
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
49. Data in the program was created by ---- and if more than one functions had to access data, ------ were used
a. variables, local variable
b. Variables, global variables
c.program name, automatic variable
d. variable, register variable
50. which of these file open mode do you use to write into the file.
a. ios ::ate
b. ios ::in
c. ios::out
d. ios ::app
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
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
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
7
55. ----- is the exception class derived from runtime_error.
a. range_error
b. lengh_error
c. bad_typeid
d. met_error
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)
59. If a function is declared virtual in its base class, you can still access it directly using the ----
a. Virtual Keyword
b. scope resolution Operator
c. Indirection Operator
d. Address Operator
60. ---- is the ability of objects belonging to different types to respond to method calls of methods of the same
name, each one according to appropriate type-specific behaviour.
a. Inheritance
b. Virtuality
c. Polymorphism
d. None of these.