You are on page 1of 13

1) Which of the following is not a type of 8) A variable defined within a block is visible

constructor? A. From the point of definition onward in the


A. Copy constructor program
B. Friend constructor B. From the point of definition onward in the
C. Default constructor function
D. Parameterized constructor C. From the point of definition onward in the
Answer: B block
D. Throughout the function
2) Which of the following is not the member of Answer: C
class?
A. Static function 9) Which of the following term is used for a
B. Friend function function defined inside a class?
C. Const function A. Member Variable
D. Virtual function B. Member function
Answer: B C. Class function
D. Classic function
3) Which of the following concepts means Answer: B
determining at runtime what method to
invoke? 10) Which of the following concept of oops
A. Data hiding allows compiler to insert arguments in a
B. Dynamic Typing function call if it is not specified?
C. Dynamic binding A. Call by value
D. Dynamic loading B. Call by reference
Answer: C C. Default arguments
D. Call by pointer
4) The friend functions are used in situations Answer: C
where:
A. We want to have access to unrelated classes 11) How many instances of an abstract class
B. Dynamic binding is required can be created?
C. Exchange of data between classes to take A. 1
place B. 5
D. None of the above C. 13
Answer: D D. 0
Answer: D
5) The keyword friend does not appear in
A. The class allowing access to another class 12) Which of the following cannot be friend?
B. The class desiring access to another class A. Function
C. The private section of a class B. Class
D. The public section of a class C. Object
Answer: C D. Operator function
Answer: C
6) The term __________ means the ability to take
many forms. 13) Which of the following concepts of OOPS
A. Inheritance means exposing only necessary information to
B. Polymorphism client?
C. Member function A. Encapsulation
D. Encapsulation B. Abstraction
Answer: B C. Data hiding
D. Data binding
7) C++ was originally developed by Answer: C
A. Clocksin and Melish
B. Donald E.Knuth
C. Sir Richard Hadlee
D. Bjarne Stroustrup
Answer: D
14) In structured programming, the problem is 21) Preventing direct access of data-members
divided into various ______. of the class from outside world is known as
A. modules ____.
B. functions (A)Polymorphism
C. structures (B)Encapsulation
D. objects (C)Data Hiding
Answer: B (D) scope resolution.
15) In Object-oriented programming, the Answer: C
problem is divided into _____.
A. classes & objects 22) What are cin and cout?
B. functions (A) pointers
C. structures (B) functions
D. modules (C) operator
Answer: A (D) stream objects
Answer: C
16) A class is ____ datatype.
A. primitive 23) Which header file must be included for cin
B. derived and cout?
C. user-defined (A) stdio.h
D. All of these (B) conio.h
Answer: C (C) iostream.h
(D) Both iostream.h and conio.h
17) A class is a collection of ____ and_____. Answer: C
(A)data-members & member functions
(B)data-members, member functions and 24) Creating a new class using one or more
main() existing classes is known as ____.
(C) data-members, member functions,main() (A)Polymorphism
and include statements (B)Encapsulation
(D)None of these (C)overloading
Answer: A (D)inheritance
Answer: D
18) An object is ......
(A)a variable of class datatype. 25) Ability of an operator or function call to
(B)same as a class. take different forms is known as ____.
(C)just like a global variable. (A) Polymorphism
(D)collection of data-members and member (B) Encapsulation
functions. (C) overloading
Answer: A (D)inheritance
Answer: A
19) Wrapping up of data & functions together 26) cout is a/an __________ .
in a class is known as _____. A. operator
(A)Overloading B. function
(B) Data Abstraction C. object
(C)Polymorphism D. macro
(D)Encapsulation Answer: C
Answer: D
27) Which of the following concepts provides
20) Including only necessary details and facility of using object of one class inside
ignoring additional details while defining a another class?
class is known as ____. A. Encapsulation
(A) Overloading B. Abstraction
(B) Data Abstraction C. Composition
(C) Polymorphism D. Inheritance
(D) Encapsulation Answer: C
Answer: B
34) Which of the following is correct about
28) How many types of polymorphisms are class and structure?
supported by C++? A. class can have member functions while
A. 1 structure cannot.
B. 2 B. class data members are public by default
C. 3 while that of structure are private.
D. 4 C. Pointer to structure or classes cannot be
Answer: B declared.
D. class data members are private by default
29) Which of the following is an abstract data while that of structure are public by default.
type? Answer: D
A. int
B. double 35) Which of the following concepts means
C. string wrapping up of data and functions together?
D. Class A. Abstraction
Answer: D B. Encapsulation
C. Inheritance
30) A __________ is a special method used to D. Polymorphism
initialize the instance variable of a class. Answer: B
A. Member function
B. Destructor 36) Which of the following concepts means
C. Constructor waiting until runtime to determine which
D. Structure function to call?
Answer: C A. Data hiding
B. Dynamic casting
31) Which of the following concepts means C. Dynamic binding
adding new components to a program as it D. Dynamic loading
runs? Answer: C
A. Data hiding
B. Dynamic typing 37) Which of the following operator is
C. Dynamic binding overloaded for object cout?
D. Dynamic loading A. >>
Answer: D B. <<
C. +
32) Which of the following statement is D. =
correct? Answer: B
A. A constructor is called at the time of
declaration of an object. 39) Which of the following is the correct class
B. A constructor is called at the time of use of of the object cout?
an object. A. iostream
C. A constructor is called at the time of B. istream
declaration of a class. C. ostream
D. A constructor is called at the time of use of a D. ifstream
class. Answer: C
Answer: A
40) Which of the following cannot be used with
33) Which of the following approach is adapted the keyword virtual?
by C++? A. class
A. Top-down B. member functions
B. Bottom-up C. constructor
C. Right-left D. destructor
D. Left-right Answer: C
Answer: B
41) Which of the following functions are
performed by a constructor? 47) Which one of the following options is
A. Construct a new class correct?
B. Construct a new object A. Friend function can access public data
C. Construct a new function members of the class.
D. Initialize objects B. Friend function can access protected data
Answer: D members of the class.
C. Friend function can access private data
42) Which of the following is the correct way of members of the class.
declaring a function as constant? D. All of the above.
A. const int ShowData(void) { /* statements */ Answer: D
}
B. int const ShowData(void) { /* statements */ 48) Which of the following statements is
} correct in C++?
C. int ShowData(void) const { /* statements */ } A. Classes cannot have data as protected
D. Both A and B members.
Answer: C B. Structures can have functions as members.
C. Class members are public by default.
43) Which of the following statement is D. Structure members are private by default.
correct? Answer: B
A. C++ allows static type checking.
B. C++ allows dynamic type checking. 49) Which of the following access specifier is
C. C++ allows static member function be of used as a default in a class definition?
type const. A. protected
D. Both A and B. B. public
Answer: D C. private
D. friend
44) Which of the following header file includes Answer: C
definition of cin and cout?
A. istream.h 50) What is correct about the static data
B. ostream.h member of a class?
C. iomanip.h A. A static member function can access only
D. iostream.h static data members of a class.
Answer: D B. A static data member is shared among all the
object of the class.
45) What will happen if a class is not having C. A static data member can be accessed
any name? directly from main().
A. It cannot have a destructor. D. Both A and B.
B. It cannot have a constructor. Answer: D
C. It is not allowed.
D. Both A and B. 51) Which of the following provides a reuse
Answer: D mechanism?
A. Abstraction
46) Which one of the following is correct about B. Inheritance
the statements given below? C. Dynamic binding
All function calls are resolved at compile- D. Encapsulation
time in Procedure Oriented Programming. Answer: B
All function calls are resolved at compile-
time in OOPS. 53) Which of the following statement is
A. Only II is correct. correct?
B. Both I and II are correct. A. Class is an instance of object.
C. Only I is correct. B. Object is an instance of a class.
D. Both I and II are incorrect. C. Class is an instance of data type.
Answer: C D. Object is an instance of data type.
Answer: B
59) Inline Functions are invoked at
53) The process of building new classes from A. Run time
existing one is called B. Compile time
A. Structure C. Depends on how it is invoked
B. Inheritance D. Both b and c above
C. Polymorphism Answer: B
D. Template
Answer: B 60) which of the following operator is used to
define member function outside the class?
54) In a class, member variables are often A. ::
called its _________, and its member functions are B. ?
sometimes referred to as its behaviour, or C. :?
____________. D. %
A. attributes, methods Answer: A
B. none of these
C. values, morals 61) function call mechanism that passes
D. data, activities arguments to a function by passing a copy of
Answer: A the values of the arguments is __________
(A)call by name
55) Which of these keywords are access (B)call by value
specifiers? (C)call by reference
A. near and far (D)call by value result
B. opened and closed Answer: B
C. table and row
D. private and public 62) Data members which are static
Answer: D (A)cannot be assigned a value
(B)can only be used in static functions
56) An Object can be declared prior to the class (C)cannot be defined in a Union
definition (D) can be accessed outside the class
A. True Answer: B
B. False:
Answer: False 63) Which of the following is false for cin?
(A)It represents standard input.
57) Use of __________ protects data from (B)It is an object of istream class.
inadvertent modifications (C)It is a class of which stream is an object.
A. protect() member function (D)Using cin the data can be read from user’s
B. private access specifier terminal
C. class protection operator, @ Answer: C
D. none of these
Answer: B 64) It is possible to declare as a friend
(A) a member function
58) A suitable place to store Class declarations (B) a global function
is _______. (C) a class
A. none of these (D) all of the above
B. their own header files Answer: D
C. Auxiliary .cpp file
D. main .cpp files, along with function 65) Given a class named Book, which of the
definitions following is not a valid constructor?
(A)Book ( ) { }
Answer: B (B)Book ( Book b) { }
(C)Book ( Book &b) { }
(D)Book (char* author, char* title) { }
Answer: B
66) How many constructors can a class have? 71) Which of the following statements are true
(A) 0 in c++?
(B) 1 (A) Classes cannot have data as public
(C) 2 members
(D) any number (B) Structures cannot have functions as
Answer: D members
(C) Class members are public by default
66) The new operator (D) None of these
A) returns a pointer to the variable Answer: B
B) creates a variable called new
C) obtains memory for a new variable 72) The following can be declared as friend in a
D) tells how much memory is available class
Answer: C (A) an object
(B) a class
67) A static function (C) a public data member
A. should be called when an object is destroyed (D) a private data member
B. is closely connected with and individual Answer: B
object of a class
C. can be called using the class name and 73) A copy constructor takes
function name (A) no argument
D. is used when a dummy object must be (B) one argument
created (C) two arguments
Answer: C (D) arbitrary no. of arguments
Answer: B
68) We can output text to an object of class
ostream using the insertion operator<< 74) Which can be passed as an argument to a
because function?
(A) the ostream class is a stream (A) constant
(B) the insertion operator works with all (B) expression
classes (C) another function
(C) we are actually outputting to cout (D) all of the above.
(D) the insertion operator is overloaded in Answer: A
ostream
Answer: D 75) Member functions, when defined within
the class specification:
69) Which of the following is not the (A) are always inline.
characteristic of constructor ? (B) are not inline.
(A) They should be declared in the public (C) are inline by default, unless they are too big
section. or too complicated.
(B) They do not have return type. (D) are not inline by default.
(C) They can not be inherited. Answer: A
(D) They can be virtual.
Answer: D 76) An entity representing some
characteristics and behaviour is-
70) A class defined within another class is: a) object
(A) Nested class b) class
(B) Inheritance c) struct
(C) Containership d) none of the above
(D) Encapsulation Answer: A
Answer: A
77) Which of the following is not the feature of 84) Which of the following features of object
OOPs? oriented programming is false?
a) Data Encapsulation a) Data is hidden and is not available to
b) Inheritance external functions.
c) Polymorphism b) New data & functions can be added easily.
d) None of the above c) Objects may communicate with each other
Answer: D through functions.
d) Emphasis is on the procedure rather than
78) The wrapping up of data and functions into data.
a single unit is Answer: D
a) Data Abstraction
b) Data Encapsulation 85) The following is the C++ style comment
c) Both (a) & (b) a) //
d) None of the above b) /*..*/
Answer: B c) –
d) None of the above
79) Which of the following feature supports Answer: A
reusability and extensibility of classes?
a) Inheritance 86) Which of the following statements is false?
b) Overloading a) Every C++ program must have a main().
c) Polymorphism b) In C++, white spaces and carriage returns
d) None of the above are ignored by the compiler.
Answer: A c) C++ statements terminate with semicolon.
d) Main() terminates with semicolon.
80) Inheritance is ………..in nature. Answer: D
a) Intransitive
b) Transitive 87) An identifier in C++
c) Both (a) & (b) a) Must begin with a letter only
d) None of the above b) Is not differentiated by cases
Answer: B c) Contains all characters as significant
81) ………… is the ability for a message or data d) None of the above
to be processed in more than one form Answer: C
a) Class
b) Abstraction 88) ………. Provides a value for a variable
c) Polymorphism a) declaration statement
d) None of the above b) assignment statement
Answer: C c) definition statement
d) None of the above
82) The smallest individual unit in a program is Answer: B
………
a) Keyword 89) A collection of variables referred under one
b) Identifier name
c) Token a) Structure
d) None of the above b) Class
Answer: C c) Union
d) None of the above
83) Which of the following features of Answer: A
procedure oriented programming is false
a) Large programs are divided into small or 90) A memory location shared by two or more
units called functions. different variables
b) Employs bottom-up approach in program a) Structure
design. b) Class
c) Most of the functions share global data. c) Union
d) None of the above. d) None of the above
Answer: B Answer: C
91) The constants defined using enum 98) << operator is
keyword are a) stream insertion operator
a) Symbols b) stream extraction operator
b) Enumerators c) left shift operator
c) Keywords d) None of the above
d) None of the above Answer: A
Answer: B
99) “H” is an example of
92) The operator ?: is a) character literal
a) Logical operator b) string literal
b) Relational operator c) variable
c) Conditional operator d) None of the above
d) Arithmetic operator Answer: B
Answer: C
100) Which of the following statements
93) A loop containing other loop is regarding comments is false?
a) Nested a) /*..*/
b) Inner b) Comment beginning with // extends to the
c) Outer end of the line
d) None of the above c) Comments may be nested
Answer: A d) Comments are used to describe a program
Answer: C
94) The following statement forces the next
iteration of the loop to take place 101) C++ is
a) break a) Procedural programming language
b) continue b) Structural programming language
c) goto c) Object oriented programming language
d) None of the above d) None of the above
Answer: B Answer: C

95) gets() function is available in 102) y=x=2; in C++ will result in


a) stdio.h a) compilation error
b) string.h b) runtime error
c) ctype.h c) assignment of value to x then to y
d) stdlib.h d) None of the above
Answer: A Answer: C

96) In C++, the statements are enclosed within 103) 31. In C++, ………. is the statement
a) parenthesis terminator
b) square brackets a) semicolon
c) curly brackets b) colon
d) None of the above c) new line
Answer: C d) None of the above
Answer: A
97) The following tells the compiler where the
program begins 104) Modules operator (%) has higher
a) Function prototype precedence than
b) Forward declaration of class a) Divide (/) operator
c) main() b) Multiply (*) operator
d) None of the above c) Negation (unary minus)
Answer: C d) Bitwise left shift operator
Answer: C
105) The result of the following statement is 110) Data members and member functions are
int y = 7; enclosed within
int ans = ++y; a) class
cout<<”ans=”<<ans; b) structure
cout<<”y”<<y; c) union
a) ans=7, y=7 d) None of the above
b) ans=8,y=7 Answer: A
c) ans=8,y=8;
d) none of the above 111) Inline functions are
Answer: C a) Declared in the class defined outside the
class
106) Consider the following if construct b) Defined outside the class using keyword
If(x=0) intime
cout<<”Inside loop!”; c) Defined inside the class using keyword inline
cout<<”Outside loop”; d) None of the above
The result of the above code segment is. Answer: B
a) inside loop
b) outside loop 112) The default class access scope is
c) both (a) & (b) a) Private
d) none of the above b) Public
Answer: B c) Protected
d) None of the above
107) The result of 2 & 3 is Answer: A
a) 2
b) 3 113) The default scope for a structure is
c) 5 a) Private
d) none of the above b) Public
Answer: A c) Protected
d) None of the above
108) Which of the following statements Answer: B
regarding enumerators is false?
a) Enumeration is an alternative method for 114) The private data members of a class are
naming integer constants/ accessible
b) An enumerator value can’t be changed in a a) Directly to objects of that class
program b) Only to the member functions
c) An integer value may be assigned to an c) To any function defined outside a class
enumerated variable d) None of the above
d) An enum defined within a structure is local Answer: B
to the structure
Answer: C 115) The objects can directly access
a) Public members
109) Which of the following statements is b) Private members
false? c) Both (a) & (b)
a) typedef defines new data types d) None of the above
b) Using typedef does not replace the standard Answer: A
C++ data type name with the new name
c) The new name defined by typedef, can be 116) The following is a valid statement in C++
used as a type for another typedef a) int x=(int)2.50;
d) None of the above b) int x=int(2.50);
Answer: A c) Both (a) & (b)
d) None of the above
Answer: C
117) Which of the following operator can be 123) When a member function of a class call
overloaded another member function, it is
a) Member access operator ( . & .*) a) Nesting of classes
b) Conditional operator (?:) b) Nesting of functions
c) Scope resolution operator (::) c) Nesting of objects
d) None of the above d) None of the above
Answer: D Answer: B

118) Using same function name to perform 124) A function defined inside a class is called
different tasks is a) A class function
a) Function polymorphism b) A friend function
b) Runtime polymorphism c) A member function
c) Function prototype d) None of the above
d) None of the above Answer: C
Answer: A
125) Information is made shareable through
119) Default argument is a) inheritance
a) Specified in function definition b) data encapsulation
b) Specified in function declaration c) data abstraction
c) Specified from left to right d) none of the above
d) None of the above Answer: A
Answer: B
126) Functions can returns
120) What is wrong with the following a) arrays
statement? b) reference
float s_interest (float principal, int rate=0.25, c) object
int time); d) all of the above
a) variables must not be specified in function Answer: D
prototype
b) arguments may only be defaulted from right 127) The memory for date members is
to left allocated
c) the default value must be specified when a) When a class is defined
making a function call b) When an object is initialized
d) none of the above c) When an object is created
Answer: B d) None of the above
Answer: B
121) Which of the following statements
regarding function overloading is not true. 128)The memory for member functions is
a) If is used to handle different data types at allocated
one place a) When a class is defined
b) When making a function call, if no exact b) When a object is created
match is found, promotion is the only criteria c) When an object is initialized
to find a match. d) None of the above
c) The default arguments can not be used Answer: A
instead of overloading
d) Unrelated functions should not be 129) The dot operator relates
overloaded a) A class member and a class object
Answer: C b) A class object and a class
122) The private members of a class c) A class and a member of that class
implement the OOP concept of d) A class object and member of that class
a) Data abstraction Answer: D
b) Data hiding
c) Message passing
d) None of the above
Answer: B
130) A class having another class definition is 137) new operator is used
a) Nested class a) to define a new variable
b) Subordinate class b) to create a new data type
c) Enclosing class c) to allocate memory dynamically
d) None of the above d) none of the above
Answer: C Answer: C

131) A class whose member functions are 138) A constructor function is generally
friends of other class is defined
a) Friend class a) In the public section of a class
b) Abstract class b) In the private section of a class
c) Virtual class c) In the protected section of a class
d) None of the above d) None of the above
Answer: A Answer: A

132) The data members of a class are 139) A class having no public constructors is
initialized a) A private class
a) in class definition b) A public class
b) by a non-member function c) An abstract class
c) through constructor function when a class d) None of the above
object is created Answer: A
d) none of the above
Answer: C 140) If a constructor function is defined in
private section of a class, then
133) A constructor function is a) The object cannot be created
a) A friend function to a class b) Only member functions and friends may
b) A member function with the same name as declare objects of the class
its class c) Both (a) & (b)
c) A non-member function d) None of the above
d) None of the above Answer: C
Answer: B
141) A constructor with no argument is
134) An enumerated type is composed of a) Default constructor
a) Integer values with user defined name b) Parameterized constructor
b) Variables of different data types c) Copy constructor
c) Constant numeric values d) None of the above
d) None of the above Answer: A
Answer: A
142) If default arguments are provided to a
135) In C++, the arguments by default are constructor function, then it becomes
passed by a) Default constructor
a) call be reference b) Copy instructor
b) call be value c) Parameterized constructor
c) both (a) & (b) d) None of the above
d) none of the above Answer: A
Answer: B
143) The class of which the objects are not
136) is an example of instantiated is
a) unary operator a) Abstract class
b) binary operator b) Virtual class
c) ternary operator c) Static class
d) none of the above d) None of the above
Answer: C Answer: A
144) && denotes 151) Which of the following statements
a) logical OR regarding constructor is false?
b) logical AND a) A constructor may be defined static
c) Bitwise AND b) Constructor can have default arguments
d) None of the above c) Member functions may be invoked from
Answer: B within a constructor
d) None of the above
145) The parameterized constructor Answer: A
a) Needs initial values as arguments during
creation of an object 152) The antonym of constructor is
b) Can be invoked explicitly only a) Creator
c) Can be invoked implicitly only b) Destructor
d) None of the above c) Destroyer
Answer: A d) None of the above
Answer: B
146) Explicit call to a constructor means
a) Providing the constructor name explicitly to 153) Variable …………. of void type
invoke it a) May be declared
b) Not providing the construction name at all b) Cannot be declared
c) Is the shorthand method c) Can be initialized
d) None of the above d) None of the above
Answer: A Answer: B

147) Classes in C++ are 154) A destruction function


a) Fundamental data type a) Takes no argument and has no return type
b) Primitive data type not even void
c) Desired data type b) Has name similar to that of class, preceded
d) None of the above by tilde(~) symbol
Answer: C c) Is used to destruct an object, constructed
through constructor function
148) A copy constructor is called d) All of the above
a) When an object is defined and initialized Answer: D
with another object
b) When an object is passed by value 155) Which of the following statements
c) When a function returns an object regarding destructor function is false?
d) All of the above a) Destructors do not accept any arguments,
Answer: D nor do they return any values
b) Destructors can be inherited
149) Which of the following regarding c) Member functions may be called from within
constructor function is false? a destructor
a) Constructor functions don’t have return d) Destructor functions are called
type, not even void automatically when an object is destroyed
b) Constructors can’t be inherited Answer: B
c) We can refer to their addresses
d) Constructors cannot be virtual 156) Function overloading
Answer: C a) Involves several function definitions under
one name, but different argument types
150) If new operator is used, then the b) Implements polymorphism
constructor function is c) Reduces the number of comparison in a
a) Parameterized constructor program, hence increases the execution speed
b) Copy constructor of a program
c) Dynamic constructor d) All of the above
d) Default constructor Answer: D
Answer: C
157) The signature of function is
a) The number & type of arguments
b) The return type of a function
c) The class definition
d) None of the above
Answer: A

158) Overloading of constructor function


a) is similar to function overloading
b) different from an overloaded function as it
can’t return a value
c) not permitted in C++
d) none of the above
Answer: B

159) The binding of a function call at runtime is


a) Static binding
b) Early binding
c) Late binding
d) Runtime binding
Answer: C

160) The process of giving special meaning to


an operator is
a) Operator overloading
b) Operator mechanism
c) Operator definition
d) None of the above
Answer: A

161) What is a comment in c++?


a) comments are parts of the source code
disregarded by the compiler
b) comments are executed by compiler to find
the meaning of the comment
c) comments are executable
d) none of the mentioned
Answer: a

162) What type of comments does c++


support?
a) single line
b) multi line
c) single line and multi line
d) none of the mentioned
Answer: C

163) What is the use of the indentation in c++?


a) distinguishes between comments and code
b) r distinguishes between comments and
outer data
c) both a and b
d) none of the mentioned
Answer: A

You might also like