Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Object Oriented Programming in C Mcqs

This document provides an overview of object oriented programming in C++. It covers key concepts like objects, classes, encapsulation, inheritance and polymorphism. It is divided into 3 units: Unit 1 defines fundamental concepts in OOP like objects, classes, data encapsulation and message passing. Unit 2 covers basic C++ programming concepts like variables, data types, operators and expressions. Unit 3 discusses arrays - which allow storing multiple values of the same type in contiguous memory locations identified by indices.

Uploaded by

muzu136055
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Object Oriented Programming in C Mcqs

This document provides an overview of object oriented programming in C++. It covers key concepts like objects, classes, encapsulation, inheritance and polymorphism. It is divided into 3 units: Unit 1 defines fundamental concepts in OOP like objects, classes, data encapsulation and message passing. Unit 2 covers basic C++ programming concepts like variables, data types, operators and expressions. Unit 3 discusses arrays - which allow storing multiple values of the same type in contiguous memory locations identified by indices.

Uploaded by

muzu136055
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

OBJECT ORIENTED PROGRAMMING IN C++

For Off Campus BSc Computer Science Programme

UNIT 1

1. The goal of programmers is to develop software that are___________.


A. Correct
B. Reliable and maintainable
C. Satisfy all the user requirements
D. All of the above
2. Software development is not a ________ process:
A. Complicated
B. Static
C. Simple
D. None of the above
3. What describes the structure of a program?
A. Programming paradigm
B. Programming methodology
C. Both (a) and (b)
D. None of the above
4. Initially, when the computers were invented, what was used to write the programs?
A. FRONTAN
B. BASIC
C. Binary program
D. None of the above
5. Any software needs to be modified or redesigned according to change in__________:
A. User requirements
B. Business rules
C. Strategies
D. All of the above
6. Then the assembly language was invented to write large programs, however, it was also
not____________.
A. Interesting
B. Easy
C. User friendly
D. None of the above
7. With the change in the user requirements, the size and the complexity of the programs continued
to grow, which led to the development of high-level languages, such as
A. FRONTAN
B. BASIC
C. Both (a) and (b)
D. Binary language
8. In unstructured programming paradigm, all the instructions of a program were written one after the
other in a single function and hence, suitable for writing only____________.
A. Small programs
B. Simple programs
C. Large and simple programs
D. Both (a) and (b
9. For large and complex programs, it became difficult to____________.
A. Trace and debug errors
B. Write programs
C. Bug errors
D. None of the above
10. To overcome the limitations of unstructured programming paradigm, which other programming
paradigms were developed?
A. Procedural programming paradigms (PPP)
B. Object-oriented programming paradigms (OOP)
C. Both (a) and (b)
D. Software programming paradigms
11. Which paradigm has revolutionized the process of software development?
A. Software programming
B. OOP
C. PPP
D. None of the above
12. The most important feature is that OOP divides the program into a number of_________.
A. Functions
B. Software
C. Objects
D. None of the above
13. An object is a unit of structural and behavioral modularity that contains a set of________.
A. Properties
B. Data
C. Associated functions
D. All of the above
14. What does OOP emphasizes on?
A. Functions
B. Data
C. Procedures
D. None of the above
15. __________are the small, self-contained and modular units with a well-defined boundary.
A. Objects
B. Data
C. Classes
D. Abstractions
16. What is defined as a user-defined data type which contains the entire set of similar data and the
functions that the objects possess?
A. Inheritance
B. Encapsulation
C. Class
D. None of the above
17. Encapsulation is the technique of binding or keeping the __________-(that operate on them)
together in a single unit called a class.
A. Data
B. Functions
C. Objects
D. Both (a) and (b)
18. Polymorphism is a _________word.
A. French
B. Latin
C. Greek
D. English
19. In C++, polymorphism can be achieved either at___________.
A. Compile time
B. Run-time
C. Both (a) and (b)
D. Virtual functions

20. What is the process of interacting between different objects in a program called?
A. Abstract classes
B. Message passing
C. Concrete classes
D. Encapsulation
UNIT 2
21. In any programming language, writing even an elementary program requires the knowledge and
clear understanding of ___________.
A. Data types
B. Variables and constants
C. Operators
D. All of the above
22. A character set can be defined as a set of characters that____________represents information.
A. Individually or in combination
B. In combination
C. Do not
D. Both (a) and (b)
23. When a program is compiled, what scans the source code and parses it into tokens to find the
syntax errors?
A. Data types
B. Compiler
C. Horizontal tab
D. None of the above
24. __________________ are the predefined words that have special significance in any
language.
A. Variables
B. Data types
C. Constants
D. Keywords
25. Every keyword is reserved for a specific purpose and hence must not be used
as__________________.
A. User-defined names
B. Identifiers
C. Plain
D. Both (a) and (b)
26. Identifiers are the names given to uniquely identify various programming elements
like________.
A. Variables and arrays
B. Functions and classes
C. Structures and namespaces
D. All of the above
27. An identifier must contain only____________.
A. Upper case and lower case letters
B. Underscore character (_) or digits 0 to 9
C. Both (a) and (b)
D. None of the above
28. What should an identifier start with?
A. Letter
B. Underscore
C. Letter or underscore
D. Digits 0 to 9
29. Identifiers that start with a double underscore ‘__’ or an underscore followed by an upper case
letter must be avoided as these names are reserved by the__________.
A. Standard C++ Library
B. Standard C Library
C. C++ Library
D. None of the above
30. Numeric constants refer to the numbers consisting of a sequence of digits (with or without
decimal point) that can be________.
A. Positive
B. Negative
C. Alphanumeric
D. Both (a) and (b)
31. In to how many categories can C++ constants be broadly classified into?
A. Four
B. Two
C. Three
D. Multiple
32. There are few character constants that cannot be included in a program directly through a
keyboard, such as__________.
A. Backspace
B. Newline
C. Both (a) and (b)
D. Insert
33. Wide character literal uses how many bytes of memory?
A. Two
B. One
C. Multiple
D. None of the above
34. A data type determines the _______________ that can be performed on the data.
A. Type
B. Operations
C. Memory
D. Both (a) and (b)
35. What is termed as a set of named integer constants that specify all the permissible values that
can be assigned to enumeration variables?
A. Enumeration
B. Reference
C. Pointer
D. None of the above
36. What forms an expression?
A. Variables
B. Constants
C. Operators
D. All of the above
37. The expressions that produce a bool type value, that is, either true or false are called______.
A. Integral expressions
B. Float expressions
C. Relational or Boolean expressions
D. Constant expressions
38. The statements that cause a set of statements to be executed repeatedly either for a specific
number of times or until some condition is satisfied are known as_____________.
A. Iteration statements or loops
B. Conditional operator
C. The if-else statement
D. The if statement
39. The bool data type can hold only boolean values that is either true or false, where true represents
________ and false represents__________.
A. 0,-1
B. 0,1
C. 1, 0
D. None of the above
40. In addition to char data type, C++ provides another data type wchar_t which is used to store
_________ wide characters.
A. 10 bit
B. 32 bit
C. 16 bit
D. 64 bit
41. Which variable stores the memory address of another variable?
A. Reference
B. Pointer
C. Array
D. None of the above
42.What are the significant features of C language?
A. Structure and union
B. Class
C. Enumerations
D. None of the above
43. If a variable is used prior to its initialization, what is produced?
A. Garbage results
B. Undesirable results
C. Both (a) and (b)
D. 10
44. The expressions that produce a bool type value after combining two or more relational
expressions are called ________________.
A. Logical expressions
B. Big Theta θ(f)
C. Boolean expressions
D. None of the above
45.____________ is an assignment expression, which is enclosed within other assignment
expression.
A. Chained assignment
B. Binary arithmetic operator
C. Compound assignment
D. Embedded assignment
46 Like built-in data types, memory can also be allocated dynamically to derived and userdefined
data types such as__________.
A. Arrays
B. Structures
C. Classes
D. All of the above
47. A single statement specifies a single action and is always terminated by a_________.
A. Inverted commas
B. Colon
C. Semi colon
D. Brackets
48. The for loop is one of the most widely used loops in____________.
A. C++
B. C
C. Iterations
D. None of the above
49. The break statement is extensively used in___________.
A. Loops
B. switch statements
C. Both (a) and (b)
D. continue statement
UNIT 3

50. Handling real world data requires a mechanism that deals with a collection of_________?
A.Structures
B. Data items
C. Arrays
D. None of the above
51. __________ is defined as a fixed size sequence of same type of data elements.
A. C++
B. Data items
C. Arrays
D. None of the above
52. What is the simplest form of an array?
A. One- dimensional array
B. Multi- dimensional array
C. Single- dimensional array

53. If more than one subscript is used, an array is known as a__________.


A. One- dimensional array
B. Single dimensional array
C. Multi- dimensional array
D. None of the above
54. The memory address of the first element of an array is contained in the _______.
A. Next array
B. Computer program
C. Name of the array
D. None of the above
55. Each element in an array is associated with a unique subscript value, starting
from__________:
A. 1 to size-1
B. 0 to size-1
C. -1 to size-0
D. None of the above
56. Once the array elements are accessed, a number of operations can be performed on them. These
operations include________.
A. Finding the sum or average
B. Maximum or minimum
C. Sorting and searching of the array elements
D. All of the above
57. A programmer can access a particular element of an array by using one or more_________
A. Indices
B. Subscripts
C. Single-dimensional array
D. Both (a) and (b)
58. Some of the common operations that can be performed on a two-dimensional array include
finding the sum of___________.
A. Row elements
B. Column elements and diagonal elements
C. Finding the maximum and minimum values
D. All of the above
59. The syntax for declaring a single-dimensional array is:
A. data_type array_name[size]
B. int marks[5]={51,62,43,74,55};
C. data_type array_name[size];
D. None of the above

60. An array can be initialized in how many ways?


A. Two
B. Three
C. One
D. None of the above
61. Multi-dimensional arrays can be described as__________.
A. Arrays of arrays
B. Arrays
C. Strings
D. None of the above
62. What is known as an index?
A. Character array
B. String
C. Subscript
D. None of the above
UNIT 4

63. How does function help programs?


A. Makes programs easy to manage
B. Makes programs easy to read
C. Both (a) and (b)
D. Makes programs easy to write
64. Functions are ____________ named groups of statements that are aimed at accomplishing a specific
task or action in the program.
A. Self-contained
B. Well-defined
C. User-defined
D. Both (a) and (b)
65. The division of a program into various functions not only enhances the ________of the
program, but also eases the debugging process.
A. Specific task or action
B. Grouping of statements
C. Readability and maintainability
D. None of the above
66. What is used to combine particular set of instructions that needs to be accessed repeatedly in a
program?
A. Array
B. String
C. Function
D. None of the above
67. The library function strcat()is commonly used in the ____________programs to concatenate two
strings.
A. Two
B. Java
C. C
D. C++
68. A function declaration is also known as____________.
A. C++ standard library
B. Variable
C. Function prototype
D. None of the above
69. Function prototype provides _________ for a function that informs the C++ compiler about the
return type, the function name, and the number and data type of the arguments passed to the function.
A. Model
B. Blueprint
C. Both (a) and (b)
D. None of the above
70. A function accepts a __________ number of parameters.
A. Multiple
B. Limited
C. Variable
D. Fixed
71. A function definition contains the __________ that specifies the actions to be performed.
A. Parameters
B. Variable
C. Code
D. None of the above
72. What does C++, the function definition comprise of?
A. Function header
B. Function body
C. Both (a) and (b)
D. Function statement
73. Function header must contain the same__________in the same order as the function prototype.
A. Return type
B. Function name
C. Parameter list
D. All of the above

74. A function header cannot be terminated by a_______.


A. Exclamation
B. Comma
C. Colon
D. Semicolon
75. The definition of the function can appear either__________-.
A. Before main()
B. After main()
C. Both (a) and (b)
D. None of the above
76. In order to use a function in different parts of a program, the function must be___________.
A. Defined
B. Declared
C. Called or invoked
D. None of the above
77. What doesn’t a function call specify?
A. Return type of the arguments
B. Data types of the arguments
C. Both (a) and (b)
D. None of the above
78. The function that calls another function is known as the _________and the function that is being
called is known as the _________.
A. Called function, calling function
B. Traversing, traversed
C. Calling function, called function
D. None of the above
79. By default, functions are called by value in__________.
A. C
B. C++
C. Programs
D. None of the above
80. If the user wants the value of an argument to be intact throughout the function then such
arguments must be declared as __________.
A. Constants
B. Reference
C. Call by value
D. Minus one
UNIT 5
81. Representing various real-world objects as program elements is one of the key objectives of
__________.
A. Object-oriented programming
B. Java
C. C++
D. C
82. In C++, this objective is accomplished with the help of two___________.
A. User-defined data types
B. Structures
C. Classes
D. All of the above
83. What binds data and functions together under a single entity?
A. C++ structures
B. Class
C. Both (a) and (b)
D. None of the above
84. C++ structures and classes are __________ in terms of their functionality.
A. Identical
B. Different
C. Entwined
D. None of the above
85. A class serves as a template that provides a layout common to all of its instances, known
as________.
A. Classes
B. Structures
C. Objects
D. None of the above
86. ___________ is a user-defined data type that binds data and the functions that operate on the data
together in a single unit.
A. Class
B. Structures
C. Objects
D. None of the above
87. Members of a class cannot be declared with the_________keywords.
A. Auto
B. Extern
C. Register
D. All of the above
88. The keywords __________are known as access specifiers (also known as visibility mode).
A. Private
B. Public
C. Protected
D. All of the above
89. The relation between an object and a class is same as that of a__________.
A. Variable and its data type
B. Function and its data type
C. Object and its data type
D. None of the above
90. Since an object is an instance of a class, the process of declaring an object of a class is known
as___________.
A. Inline function
B. Instantiation
C. Built-in data types
D. None of the above
91. Arrays can be declared as the members of a__________.
A. Class
B. Queue
C. String
D. None of the above
92. The arrays can be declared as____________members of the class.
A. Private
B. Public
C. Protected
D. All of the above
93. The objects of a class can be passed as arguments to member functions as well as nonmember
functions by___________.
A. Value
B. Reference
C. Both (a) and (b)
D. None of the above
94. In how many situations can friend function be generally used?
A. Two
B. Three
C. One
D. None of the situations
95. In C++, a class can simultaneously have a__________.
A. Default constructor
B. Parameterized constructor
C. Copy constructor
D. All of the above
96. When an object is initialized with an overloaded constructor, the compiler determines which constructor is
to be called based on the number___________.
A. Order
B. Order of the parameters
C. Both (a) and (b)
D. None of the above
97. The constructor and the destructor of a class are automatically invoked when memory is allocated
and de-allocated to an___________.
A. Data type
B. Copy constructor
C. Object
D. None of the above
98. The public members of a class can be accessed outside the class directly using the___________.
A. Object name
B. Dot operator
C. Both (a) and (b)
D. Memory space
UNIT 6
99. C++ permits to perform all the _________operations on the objects of a class in the same way as
these are performed on simple variables.
A. Arithmetic
B. Logical
C. Overloading
D. Both (a) and (b)
100. Which process enables an operator to exhibit different behavior, depending on the data being
provided?
A. Operator overloading
B. Object overloading
C. Built in-data types
D. None of the above
101. An operator is overloaded with the help of a special function called an___________.
A. Operator function
B. Operator overloading
C. Dot operator (.)
D. None of the above
102. An operator can be overloaded either using___________.
A. Member functions
B. Friend functions
C. Both (a) and (b)
D. Operator function
103. If the member operator function is defined outside the class, it has to be first declared inside
the___________.
A. Class
B. Object
C. Program
D. None of the above
104. The parameter_list has no arguments for unary operators, except for what?
A. Postfix forms of ++
B. — operators
C. Both (a) and (b)
D. Function body
105. Which forms does C++ enable to overload?
A. Prefix
B. Postfix
C. Both (a) and (b)
D. None of the above
106. If the overloaded functions for ++ and — operators have return type void, then they cannot
be used in an_________.
A. Expressions
B. Assignment statement
C. Overloading increment
D. Both (a) and (b)
107. On how many operands do binary operators operate on?
A. Two
B. Three
C. Four
D. One
108. How many types of type conversions in an expression involving user-defined data types can be
there?
A. Three
B. Four
C. Two
D. None
109. When one class type is to be converted into another class type, the class type (object) that
appears on the right-hand side is known as______________.
A. Source class
B. Destination class
C. Casting operator function
D. None of the above
110. Which keyword is used to overload an operator?
A. operator

B. explicit call
C. operator float

D. None of the above

111. The conversion function cannot have an argument list or a___________.


A. Return type
B. Basic type
C. Class type
D. None of the above
112. If the data members of the class need to be incremented or decremented by some value other
than 1, then instead of overloading the postfix forms of increment or decrement operators, the
_________can be overloaded.
A. Shorthand operators (+= and -=)
B. Overloading binary operators
C. Conversion function
D. None of the above
UNIT 7
113. Which is one of the major strengths of object-oriented programming?
A. Logic
B. Inheritance
C. Memory
D. None of the above
114. The logical relationship between classes is achieved by_________.
A. Inheritance
B. Virtual base classes
C. Derived classes
D. None of the above
115. Inheritance facilitates a class to acquire the ____________of the existing class.
A. Properties
B. Functionality
C. Both (a) and (b)
D. None of the above
116. In inheritance, the class which is inherited by the new class is known as_________.
A. Base class
B. Superclass
C. Parent
D. All of the above
117. The class which inherits the members of the existing class is known as___________.
A. Derived class
B. Sub class
C. Child class
D. All of the above
118. The private members are accessed indirectly using the protected and the public member
functions of the __________.
A. Sub class
B. Base class
C. Derived class
D. None of the above
119. Depending on the access specifiers public, protected or private, a base class can
be____________.

A. Publicly inherited
B. Protectedly inherited
C. Privately inherited
D. All of the above
120. When the access specifier of the base class in the derived class definition is public, the base
class is __________.
A. Publicly inherited
B. Protectedly inherited
C. Privately inherited
D. None of the above
121. When a base class is protectedly inherited, public and protected members of the base class are
not accessible by the objects of the__________.
A. Base class
B. Derived class
C. Friend classes
D. Member functions
122. By default, the access specifier of a base class in the derived class definition is_________.
A. protected member
B. perimeter
C. private base_class
D. private
123. What is also allocated to the objects of a class?
A. Array
B. Memory
C. Variables
D. None of the above
124. When a derived class inherits from a single base class, it is referred to as_________.
A. Hybrid inheritance
B. Multiple inheritances
C. Single inheritance
D. Multi-level inheritance
125. The size of an object of the derived class is equal to the sum of the size of all the data members
of the___________.
A. Base class
B. Derived class
C. Both (a) and (b)
D. Virtual base class
126. When a derived class inherits from more than one base class simultaneously, it is referred to
as___________.
A. Hybrid inheritance
B. Multiple inheritances
C. Single inheritance
D. Multi-level inheritance
127. Multilevel inheritance comprises of how many levels?
A. Only two
B. Two or more
C. More than three
D. None of the above
128. Virtual base class is an indirect base class declared using the keyword _________in order to
prevent its duplication.
A. derived
B. derived_class
C. virtual
D. None of the above
129. What is required in inheritance to initialize the data members of the base class through derived
class?
A. Object declaration
B. Destructor
C. Constructor
D. Inheritance
130. What are used to dynamically initialize the object of the class?
A. base class constructor
B. Parameterized constructors
C. Destructor of the virtual base class
D. None of the above
UNIT 8

131. Every program occupies some memory space during its___________.


A. Execution
B. Initialization
C. Implementation
D. None of the above
132. The addresses of which elements can be accessed in the program through the use of pointers,
and are vital to C++ programming?
A. Variables
B. Literals
C. Both (a) and (b)
D. Pointers
133. Which features of C++ require the use of pointers?
A. Virtual functions
B. this pointer
C. Variables
D. Both (a) and (b)
134. A pointer is a variable that stores the address (not the value) of another_________.
A. Variable
B. Literal
C. Both (a) and (b)
D. None of the above
135. Like other variables, what else must be declared before using it in the program?
A. Data types
B. Literal variable
C. An asterisk ‘*’
D. Pointer variable
136. A pointer currently not pointing to any valid memory address can be initialized with______.
A. NULL
B. 1
C. -1
D. None of the above
137. A pointer initialized with NULL is called a________?
A. Reference operator
B. NULL pointer
C. Pointer variable ptr
D. None of the above
138. In C++, the reference operator (&) is used for how many distinct purposes?
A. Two
B. Three
C. Four
D. Multiple
139. Which unary operator is used with a pointer variable to ‘indirectly’ access the contents of the
memory location pointed to by the pointer (that is dereferencing a pointer)?
A. Indirection operator
B. Dereference (*) operator
C. Both (a) and (b)
D. Pointer
140. The syntax for dereferencing a pointer variable is_______________.
A. pointer-name
B. pointer_name
C. *pointer_name
D. None of the above
141. An expression that involves pointer variables and various arithmetic, relational and other
operators, is known as a__________.
A. Pointer arithmetic
B. Dereferencing pointers
C. NULL pointer
D. None of the above
142. What is closely related to pointers?
A. Arrays
B. Nodes
C. Syntaxes
D. None of the above
143. Where is it important to distinguish while using asterisk (*) ?
A. Dereferencing pointers
B. Declaration of pointers
C. Both (a) and (b)
D. Pointer declaration
144. In addition to the array notation, pointer notation can be applied to characters in a C-string using
a pointer of type______.
A. float
B. int
C. char
D. long or double
145. Which special pointer contains the address of an object of a class currently calling the member
function of the class?
A. this pointer
B. char (ename)
C. class_name *pointer_name[size];
D. None of the above
146. __________are one of the attributes of C++ that support run-time polymorphism.
A. Pointers
B. Derived classes
C. Virtual functions
D. Heap tree
147. What stores the base addresses of all the virtual functions defined in the class?
A. V-table
B. Virtual table
C. Both (a) and (b)
D. Polymorphism
148. A virtual function having no definition within the base class is called__________.
A. Abstract classes
B. Pure virtual function
C. Virtual destructors
D. None of the above
149. A class that contains at least one pure virtual function is known as an__________.
A. Abstract class
B. Pure abstract class
C. Pure virtual functions
D. Both (a) and (b)

UNIT 9

150. Most real-life applications require large amount of input and output data to be handled that is
difficult to manage using the commonly used console input/output (I/O) devices like_________.
A. Keyboard
B. Screen
C. Mouse
D. Both (a) and (b)
151. With what type of devices can the C++ I/O system function?
A. Terminals
B. Disks
C. Tape drives
D. All of the above
152. __________ refers to the flow of data in the form of sequence of bytes.
A. Stream
B. C++ I/O system
C. I/O operations
D. All of the above
153. The streams help to consume data from which all sources?
A. Keyboard
B. Mouse
C. Storage device
D. All of the above
154. Streams also receive data from the program and direct it to the___________.
A. Different programs
B. Physical devices
C. Both (a) and (b)
D. Files
155. What is a collection of related data stored on some storage device called?
A. Arrays
B. Streams
C. Files
D. Pointers
156. A file stream refers to the flow of data between__________.
A. Programs
B. Files
C. Newline character
D. Both (a) and (b)
157. If a number, say12345, is stored in text format, it occupies how many bytes of memory?
A. Five
B. Two
C. Three
D. One
158. Since data is stored in the same format as in the internal memory, saving and accessing the data
from binary files is ___________ than the text files.
A. Staggered
B. Slower
C. Faster
D. None of the above
159. Which input file stream class provides functions for performing reading operations only?
A. ifstream
B. istream class
C. read()
D. None of the above
160. What is used to manage the buffered I/O of file stream?
A. ifstream
B. filebuf
C. ofstream
D. None of the above
161. The fstream contains all the functions of __________ classes which are inherited through
iostream class.
A. istream
B. ostream
C. Both (a) and (b)
D. None of the above
162. To perform any operation on a file, it needs to be_________first.
A. Cleaned
B. Opened
C. Closed
D. Organized
163. In C++, each file is __________ of a particular stream class.
A. An argument
B. A function
C. An object
D. None of the above
164. The functions ________also known as binary I/O functions are used to handle blocks of binary
data.
A. read()
B. write()
C. Both (a) and (b)
D. get(and put())
165. The process of reading and writing sequence of bytes is known__________.
A. Object serialization
B. Binary serialization
C. Both (a) and (b)
D. Streams
166. Which signal can be detected by using the function eof()which is a member function of the ios
class?
A. End-of-file (EOF)
B. streamsize gcount();
C. char title[30];
D. None of the above
167. In C++, every file is associated with how many file pointers?
A. Three
B. Two
C. Four
D. One
168. A file stream refers to the flow of data between a__________.
A. Program and object
B. Program and stream
C. Program and file
D. None of the above
169. Depending on the flow of data from file or to file, stream can be classified into___________.
A. Input stream and output stream
B. Mode and binary mode
C. ofstream and fstream
D. None of the above
UNIT 10

170. ____________ main advantage of object-oriented programming.


A. Code usability
B. Code reusability
C. Templates
D. None of the above
171. a sum() function defined to add two integers can be called any number of times with
different___________.
A. Integer values
B. Templates
C. Codes
D. None of the above
172. Templates are also known as_________?
A. Generics
B. Parameterized types
C. Both (a) and (b)
D. None of the above
173. Who writes the same code repeatedly for different data types (as in the case of overloaded
functions)?
A. Coder
B. Mathematician
C. Programmer
D. None of the above
174. The C++ template mechanism allows a generic type to be passed as a parameter in the definition
of a ___________so that they can work with different types of data?
A. Function
B. Class
C. Both (a) and (b)
D. Integer
175. What is the main advantage of using a template?
A. Reduces the size of the source code
B. Increases code flexibility
C. Writes the same code
D. Both (a) and (b)
176. When templates are used with functions they are known as__________.
A. Function templates
B. Class templates
C. Generic programming
D. Data structures
177. Which of the following statements is correct?
(i) A function template, also known as a generic function.
(ii) The definition of templates is dissimilar to the definition of ordinary functions.
A. (ii) only
B. (i) only
C. Both are correct
D. None are correct
178. While using function templates, only __________- function signature needs to be defined.
A. Two
B. One
C. Three
D. None of the above
179. When a template is defined, what does it provide in order to generate many functions?
A. Blueprint
B. Syntactical skeleton
C. Both (a) and (b)
D. Syntax
180. After defining the function template, the next step is to call it in another function such as_____.
A. int
B. sum() function
C. double data type
D. in main()
181. How many parameters does the function template sum()accept?
A. Two
B. Three
C. One
D. None of the above
182. While using class templates, how many class definition needs to be created?
A. One
B. Two
C. Three
D. None
183. A class template is used in those situations where ________have thesame class definition but
handle different data types.
A. One or more classes
B. Two or more classes
C. One
D. None of the above
184. Inheritance provides a way to re-use the object code, whereas a template provides a way to re-
use the___________.
A. Source code
B. Templates
C. Arguments
D. None of the above
185. ___________ is an approach of writing programs in which a generic type is passed as a
parameter in the definition of a function or a class so that they can work with different types of data.
A. Object-oriented programming
B. Function template
C. Specialization
D. Generic programming
UNIT 11

186. The exceptions that occur at specific program statements are called__________.
A. Synchronous exceptions
B. Exception handling
C. Asynchronous exceptions
D. None of the above
187. The point within the function at which the throw statement is executed is called the_________.
A. Throw point
B. Synchronous exceptions
C. Asynchronous exceptions
D. None of the above
188. How many types of exceptions are there?
A. Three
B. Two
C. One
D. None of the above
189. An exception is an unexpected event that occurs during the execution of a___________.
A. Statement
B. Code
C. Program
D. None of the above
190. C++ exception handling mechanism mainly uses how many keywords?
A. Four
B. Three
C. Two
D. None of the above
191. What allows multiple catch blocks to handle different types of exceptions?
A. C
B. C++
C. Exceptions
D. None of the above
192. A throw statement without any argument is used to rethrow an________.
A. Try block
B. Catch block
C. Exception
D. None of the above
193. The calling function checks for the return values and then appropriately handles
the___________.
A. Exceptions
B. Error
C. Both (a) and (b)
D. None of the above
194.____________ an exception allows multiple handlers to access the same exception.
A. Blocking
B. Throwing
C. Rethrowing
D. None of the above
195. Sometimes it is not possible to predict all types of exceptions that can occur during the program
execution and hence, separate __________- cannot be provided to handle all the exceptions.
A. Try block
B. Ellipsis (...)
C. Catch blocks
D. Executions
196. Whenever an exception is thrown, ___________ are searched in sequential order for an
appropriate match.
A. Try block
B. Executions
C. Catch blocks
D. Programs
197. When an exception is thrown, it needs to be______________.
A. Executed
B. Handled appropriately
C. Resolved
D. None of the above
198. Whenever an exception occurs it is thrown using the____________.
A. User-defined function
B. throw exception
C. throw statement
D. None of the above
199. The argument exception used with the throw statement can be either of built-in data
type such as____________ or a user-defined data type such as class, struct, etc.
A. float
B. int
C. Both (a) and (b)
D. throw;
200. The point within the function at which the throw statement is executed is called the
__________.
A. Try block
B. Throw point
C. Catch block
D. None of the above

You might also like