1. Which of the following type of class allows only one object of it to be create
d? (A) Virtual class (B) Abstract class (C) Singleton class (D) Friend class
(C)
2. Which of the following is not a type of constructor? (A) Copy constructor (B) Friend constructor (C) Default constructor (D) Parameterized constructor 3. Which of the following statements is correct? (A) Base class pointer cannot point to derived class. (B) Derived class pointer cannot point to base class. (C) Pointer to derived class cannot be create (D) Pointer to base class cannot be create
(B)
(B)
4. Which of the following is not the member of class? (A) Static function (B) Friend function (C) Const function (D) Virtual function (B) 5. Which of the following concepts means determining at runtime what method to i nvoke? (A) Data hiding (B) Dynamic Typing (C) Dynamic binding (D) Dynamic loading (C) 6. Which of the following term is used for a function defined inside a class? (A) Member Variable (B) Member function (C) Class function (D) Classic function (B) 7. Which of a function (A) Call by (C) Default
the following concept of oops allows compiler to insert arguments in call if it is not specified? value (B) Call by reference arguments (D) Call by pointer (C)
8. How many instances of an abstract class can be created? (A) 1 (B) 5 (C) 13 (D) 0 (D) 9. Which of the following cannot be friend? (A) Function Function (B) Class Class (C) Object Object (D) Operator Operator function function (C) 10. Which of the following concepts of OOPS means exposing only necessary inform ation to client? (A) (A) Enc Encap apsu sula lati tion on (B) (B) Abst Abstra ract ctio ion n (C) (C) Data Data hidi hiding ng (D) (D) Data Data bind bindin ing g (C) (C) 11. (A) (B) (C) (D)
Why reference is not same as a pointer? A reference can never be null. A reference once established cannot be change Reference doesn't need an explicit dereferencing mechanism. All of the above. (D)
12. cout is a/an __________ . (A) oper operato ator r (B) functi function on (C) (C) object object (D) (D) macro macro
(C)
13. Which of the following concepts provides facility of using object of one cla ss inside another class? (A) Encap ncapsu sula lati tion on (B) (B) Abs Abst tract ractio ion n (C) (C) Comp Compos osit itio ion n (D) (D) Inhe Inheri rita tanc nce e (C) (C) 14. How many types of polymorphisms are supported by C++? (A) 1 (B) 2 (C) 3 (D) 4 (B) 15. Which of the following is an abstract data type?
(A) int (B) double (C) string (D) Class
(D)
16. Which of the following concepts means adding new components to a program as it runs? (A) Data hiding (B) Dynamic typing (C) Dynamic binding (D) Dynamic loading (D) 17. (A) (B) (C) (D)
Which of the following statement is A constructor is called at the time A constructor is called at the time A constructor is called at the time A constructor is called at the time
correct? of declaration of an object. of use of an object. of declaration of a class. of use of a class.
18. (A) (B) (C) (D)
Which of the following correctly describes overloading of functions? Virtual polymorphism Transient polymorphism Ad-hoc polymorphism Pseudo polymorphism (C)
19. Which of the following approach is adapted by C++? (A) Top-down (B) Bottom-up (C) Right-left (D) Left-right
(A)
(B)
20. (A) (B) (C) (D)
Which of the following is correct about function overloading? The types of arguments are different. The order of argument is different. The number of argument is same. Both A and B (D)
21. (A) (B) . (C) (D) by
Which of the following is correct about class and structure? class can have member functions while structure cannot. class data members are public by default while that of structure are private Pointer to structure or classes cannot be declare class data members are private by default while that of structure are public default.
(D) 22. Which of the following concepts means wrapping up of data and functions toge ther? (A) (A) Abs Abstr trac acti tion on (B) (B) Enc Encap apsu sula lati tion on (C) (C) Inh Inher erit itan ance ce (D) (D) Pol Polym ymor orph phis ism m (B) (B) 23. Which of the following concepts means waiting until runtime to determine whi ch function to call? (A) Data hiding (B) Dynamic casting (C) Dynamic binding (D) Dynamic loading (C) 24. How "Late binding" is implemented in C++? (A) Using C++ tables (B) Using Virtual tables (C) Using Using Inde Indexed xed virtua virtual l table tables s (D) (D) Using Using polymo polymorph rphic ic tabl tables es
(B)
25. Which of the following operator is overloaded for object cout? (A) >> (B) << (C) + (D) = (B) 26. Which of the following is the correct class of the object cout? (A) iostream (B) istream (C) ostream (D) ifstream (A) 27. Which of the following cannot be used with the keyword virtual? (A) class class (B) (B) memb member er func functio tions ns (C) (C) cons constru tructo ctor r (D) (D) destr destruct uctor or (C)
(A) int (B) double (C) string (D) Class
(D)
16. Which of the following concepts means adding new components to a program as it runs? (A) Data hiding (B) Dynamic typing (C) Dynamic binding (D) Dynamic loading (D) 17. (A) (B) (C) (D)
Which of the following statement is A constructor is called at the time A constructor is called at the time A constructor is called at the time A constructor is called at the time
correct? of declaration of an object. of use of an object. of declaration of a class. of use of a class.
18. (A) (B) (C) (D)
Which of the following correctly describes overloading of functions? Virtual polymorphism Transient polymorphism Ad-hoc polymorphism Pseudo polymorphism (C)
19. Which of the following approach is adapted by C++? (A) Top-down (B) Bottom-up (C) Right-left (D) Left-right
(A)
(B)
20. (A) (B) (C) (D)
Which of the following is correct about function overloading? The types of arguments are different. The order of argument is different. The number of argument is same. Both A and B (D)
21. (A) (B) . (C) (D) by
Which of the following is correct about class and structure? class can have member functions while structure cannot. class data members are public by default while that of structure are private Pointer to structure or classes cannot be declare class data members are private by default while that of structure are public default.
(D) 22. Which of the following concepts means wrapping up of data and functions toge ther? (A) (A) Abs Abstr trac acti tion on (B) (B) Enc Encap apsu sula lati tion on (C) (C) Inh Inher erit itan ance ce (D) (D) Pol Polym ymor orph phis ism m (B) (B) 23. Which of the following concepts means waiting until runtime to determine whi ch function to call? (A) Data hiding (B) Dynamic casting (C) Dynamic binding (D) Dynamic loading (C) 24. How "Late binding" is implemented in C++? (A) Using C++ tables (B) Using Virtual tables (C) Using Using Inde Indexed xed virtua virtual l table tables s (D) (D) Using Using polymo polymorph rphic ic tabl tables es
(B)
25. Which of the following operator is overloaded for object cout? (A) >> (B) << (C) + (D) = (B) 26. Which of the following is the correct class of the object cout? (A) iostream (B) istream (C) ostream (D) ifstream (A) 27. Which of the following cannot be used with the keyword virtual? (A) class class (B) (B) memb member er func functio tions ns (C) (C) cons constru tructo ctor r (D) (D) destr destruct uctor or (C)
28. Which of the following functions are performed by a constructor? (A) Construct a new class (B) Construct a new object (C) (C) Cons Constr truc uct t a new new func functi tion on (D) (D) Init Initia iali lize ze obje object cts s (D) (D) 29. (A) (B) (C) (D)
Which of the following problem causes an exception? Missing semicolon in statement in main(). A problem in calling function. A syntax error. run-time error. (D)
30. Which one of the following options is correct about the statement given belo w? The compiler checks the type of reference in the object and not the type of o bject. (A) (A) Inh Inher erit itan ance ce (B) (B) Pol Polym ymor orph phis ism m (C) (C) Abst Abstra ract ctio ion n (D) (D) Enca Encaps psul ulat atio ion n (B) (B) 31. t? (A) (B) (C) (D)
Which of the following is the correct way of declaring a function as constan const int ShowData(void) { /* statements */ } int const ShowData(void) { /* statements */ } int ShowData(void) const { /* statements */ } none of above (C)
32. Which of the following concepts is used to implement late binding? (A) Virtual function (B) Operator function (C) Const Const functi function on (D) Static Static functi function on (A) 33. (A) (B) (C) (D)
Which of the following statement is correct? C++ allows static type checking. C++ allows dynamic type checking. C++ allows static member function be of type const. Both A and (B) (D)
34. Which of the following factors supports the statement that reusability is a desirable feature of a language? (A) It decreases the testing time. (B) It lowers the maintenance cost. (C) It reduces the compilation time. (D) Both A and B (D) 35. Which of the following ways are legal to access a class data member using th is pointer? (A) this->x (B) this.x (C) *this.x (D) *this-x (A) 36. 3.4E - 38 38 is equivalent to ? (A) 3.4 x 10 x 38 (B) 3.4 x 38 (C) 3.4 x 10-38 (D) None of these 37. (A) (B) (C) (D)
A floating point number contains......? Both integral and fractional part Fractional part only Integral part only None of these
38. (A) (B) (C) (D)
Which statement is most appropriate for C++ language ? Type Less language Statically types Language Dynamically typed language Both B and C (B)
(A)
39. Keyword used for Dynamic method resolution ? (A) abstract abstract (B) (B) dynamic dynamic (C) virtual virtual (D) (D) typeid typeid (C)
(C)
40. (A) (B) (C) (D)
Which of the following is not a feature of C++ ? Operator overloading Namespaces Inheritance Reflection (D)
41. (A) (B) (C) (D)
The term STL stands for ? Simple Template Library Static Template Library Single Type Based Library Standard Template Library
42. tic (A) (B) (C) (D)
What is the implicit pointer that is passed as the first argument for nonsta member functions ? self pointer std::auto_ptr pointer myself pointer this pointer (D)
(D)
43. What is the right way to declare a copy constructor of a class if the name o f class is X ? (a) X(const X* arg) (b) X( const X& arg) (c) X(X arg) (d) X(X* arg) (B) 44. (A) (B) (C) (D)
Which of the following operator can not be overloaded ? Scope resolution operator Arrow operator Equality operator Assignment operator (A)
45. (A) (B) (C) (D)
How do we declare an interface class ? By declaring the class as interface with keyword interface By making all the methods abstract using the keyword abstract in class By making all the methods pure virtual in class It is not possible to create interface classes in c++ (C)
46. What is a size of empty class in c++? (A) 4 bytes (B) 2 bytes (C) 0 bytes (D) 1 bytes 47. In c++ object of the class is also called? (A) Constants (B) Tag (C) Instance (D) Data collection
(D) (C)
48. ________ is a default access specifier specifier for members members of class in C++. (A) protected (B) public (C) private (D) default (C ) 49. ________ is a default access specifier for members of structures in C++. (A) protected (B) public (C) private (D) default (B) 50. In object oriented programming, by wrapping up characteristics and behavior into one unit, we achieve (A) Data Abstraction (B) Data Encapsulation (C) Data Hiding (D) All of these (B) 50. Which of the following mode declaration is used in C++ to open a file for in put? (A) ios :: app app (B) (B) in :: ios (C) ios :: in (D) (D) ios ios :: file file (C) (C)
51. Which diagram provides a formal graphic notation for modelling objects, clas ses and their relationships to one another? (A) Object Diagram (B) Analysis Diagram (C) Instance Diagram (D) Class Diagram (A) 52. The mechanism that binds code and data together and keeps them secure from o utside world is known as (A) (A) Abs Abstr trac acti tion on (B) (B) Enc Encap apsu sula lati tion on (C) (C) Inh Inher erit itan ance ce (D) (D) Pol Polym ymor orph phis ism m (B) (B) 53. The principle of __________ allows us to create new classes based on existin g classes. (A) none of these (B) copy construction (C) function overloading (D) inheritance (b) 54. When you derive a class privately, a protected base class member becomes (A) private (B) public (C) not inherited (D) protected (A) 55. Irrespective of type of derivation __________ members of a base class are ne ver accessible in derived class. (A) private (B) none of these (C) protected (D) public (B) 56. A class inherited from an existing class is known as _____________. (A) derived class (B) inheritee (C) base class (D) none of these (A) ------------------------------------------------------------------------------------------------------------------------------------------57. In C++ ..................... operator is used for Dynamic memory allocation. (A) (A) Sco Scope pe reso resolu luti tion on (B) (B) Con Condi diti tion onal al (C) (C) New New (D) (D) Mem Membe bers rshi hip p acc acces ess s (C) (C) 58. Operators such as ...................... cannot be overloaded. (A) + (B) ++ (C) : : (D) = = (C) 59. The ...................... objects have values that can be tested for variou s error conditions. (A) os osstream (B (B) of ofstream (C (C) st stream (D (D) if ifstream (D) 60. Which function return the current position of the get or put pointer in byte s. (A) tellg( tellg( ) (B) (B) tellp tellp( ( ) (C) (C) tell( tell( ) (D) (D) Both Both A and and B (B) 61. The first index number in an array starts with ............................ and the index number of an array of size n will be ............ (A) 0, n-1 (B) 1, n-1 (C) 0, n (D) 1, n (A) 62. To overload an operator ..................... keyword must be used along wit h the operator to be overloaded. (A) Over (B) Overload (C) Void (D) Operator (D) 63. What is the output of the program #include
void main() { int n=1; cout<
(A) Print natural numbers 0 to 99 (B) Print natural numbers 1 to 99 (C) Print natural numbers 0 to 100 (D) Print natural numbers 1 to 100
(D)
64. Everything defined at the program scope level (ie. outside functions and cla sses) is said to be ............... (A) local scope (B) regional scope (C) global scope (D) static scope (C) 65. Because the lifetime of a local variable is limited and determined automatic ally, these variables are also called ............................ (A) automator (B) automatic (C) dynamic (D) static (B) 66. ................ allows that a section of a program is compiled only if the defined constant that is specified as the parameter has been defined, independen tly of its value. (A) #ifdef (B) #if (C) #define (D) #ifd (A) -------------------------------67. C++ is an extension of C with a major addition of the class construct featur e of .............. (A) Simula67 (B) Simula57 (C) Simula47 (D) Simula87 (A) 68. (A) (B) (C) (D)
C++ has the name ............. before it was changed to C++. Improved C Integrated C C with classes C with (C)
69. ............ Refer to the names of variables, functions, arrays, classes etc . created by the programmer. (A) Keywords (B) Identifiers (C) Constraints (D) Strings (B) 70. (A) (B) (C) (D)
In C++, the keyword void was used 厖 .. To specify the return type of function when it is not returning any value. To indicate an empty argument list to a function. To declare the generic pointers. All of the above. (D)
71. (a) (b) (c)
Match the following : : : :* ->*
(A) (B) (C) (D)
a-ii, b-iii, c-i a-iii, b-i, c-ii a-i b-ii, c-iii a-iii, b-ii, c-i
(i) Pointer to member declarator (ii) Pointer to member operator (iii) Scope resolution operator
(B)
72. If m and n are int type variables, what will be the result of the expression m% n when m=5 and n=2 ? (A) 0 (B) 1 (C) 2 (D) None of the above (B)
73. Some of the C++ operators cannot overloaded which are (i) Member access operators (. And .*) (ii) Conditional operat or (? :) (iii) Scope resolution operator (: :) (iv) Size operato r (sizeof) (A) only i, ii and iii (B) only ii, iii and iv (C) only ii and iv (D) All i, ii, iii and iv (D) 74. (A) (B) (C) (D)
Some of the situations where inline expansion may not work are: For functions returning values, if a loop, a switch or goto exists. If functions contain static variables and they are re-cursive. For functions not returning values, if return statement exist. All of the above. (D)
75. (A) (B) (C) (D)
Which of the following control expressions are valid for an if statement? an integer expression a Boolean expression either A or B Neither A nor B (B)
76. .......... is a way to bind the data and its associated functions together w hich allows the data and functions to be hidden. (A) Structure (B) Class (C) Enum (D) Both A and B (B) ----------------------------------------------------Polymorphism 77.Ability to take many forms is called ________. (A)polymorphism (B) encapsulation (C) member function (D) inheritance (B) 78. (A) (B) (C) (D)
The run time system performs __________ on virtual functions. none of these additional error checking dynamic binding static binding (B)
79. (A) (B) (C) (D)
A _____________ pointer can point to ____________ object. derived class, base class void, derived class void, NULL base class, derived class (D)
80. A virtual function is a member function that expects to be _________ in a de rived class. (A) private (B) none of these (C) overridden (D) ignored (C) 81. For proper display of polymorphism, a method in the base class must be decla red _______. (A) private (B) public (C) protected (D) virtual (D) 82. The principle of__________allows us to create new classes based on existing classes. (A) polymorphism (B) copy construction (C) function overloading (D) inheritance (B) 83. When you derive a class privately, a protected base class member becomes (A) private
(B) public (C) not inherited (D) protected
(A)
84. Irrespective of type of derivation__________members of a base class are neve r accessible in derived class. (A) public (B) private (C) protected (D) none of these (B) 85. A class inherited from an existing class is known as _____________. (A) derived class (B) inheritee (C) child class (D) a and c (D) 86. When a class serves as base class for many derived classes, the situation is called: (A) polymorphism (B) hierarchical inheritance (C) hybrid inheritance (D) multipath inheritance (B) 87. When two or more classes serve as base class for a derived class, the si tuation is known as __________. (A) multiple inheritance (B) polymorphism (C) encapsulation (D) hierarchical inheritance (A) 88.Multiple inheritance leaves room for a derived class to have _______ members. (A)dynamic (B)private (C)public (D)ambiguous 89. (A) (B) (C) (D)
(D)
Hybrid inheritance is ___________. multiple inheritance multilevel inheritance multipath inheritance combination of a and b (D)
90. Object _______ and operator _______ are used for reading. (A) cin >> (B) cout >> (C) cin << (D) cout << (A) 91.For reading with cin object, we need to include __________file. (A)conio.h (B)fstream.h (C)stdio.h (D)iostream.h (D) 92.Manipulators without parameters such as endl, hex, dec etc are defined in ___ _______ file. (A)iomanip.h (B)conio.h (C)io.h (D)none of the above (D) 93.Which of the following is not a manipulator. (A) dec (B) scientific (C) endl (D) flush 94.Of the following _________ is not an ios flag.
(B)
(A)dec (B)showbase (C)hex (D)flush 95. (A) (B) (C) (D)
(D)
Statement cin >> ch ; will start executing when we press _______ key. any any character only character enter (D)
Pointer 96. When the ___________ is present in front of a variable name, it represents t he address of that variable. (A)asterisk ( * ) (B)conditional operator (C)ampersand ( & ) (D)semicolon ( ; ) (C) 97.A pointer variable may be initialized with (A)any non-zero integer value (B)any address in the computer's memory (C)the address of an existing variable (D)a and c only (B) 98.A pointer variable is designed to store ________. (A)any legal C++ value (B)only floating-point values (C)a memory address (D)a float value (C) 99.We should use the delete operator for objects that were ________. (A)never used (B)not correctly initialized (C)created with the new operator (D)dereferenced inappropriately (C) Polymorphism 100.Ability to take many forms is called ________. (A)inheritance (B)polymorphism (C)encapsulation (D)member function (B) 101.The run time system performs __________ on virtual functions. (A)none of these (B)additional error checking (C)dynamic binding (D)static binding (B) 102. A _____________ pointer can point to ____________ object. (A) derived class, base class (B) void, derived class (C) void, NULL (D) base class, derived class (D) 103. A virtual function is a member function that expects to be _________ in a d erived class. (A) private (B) none of these (C) overridden (D) ignored (C)
104. For proper display of polymorphism, a method in the base class must be decl ared _______. (A) private (B) public (C) protected (D) virtual (D) File handling 105. In order, the three-step process of using a file in a C++ program involves: (A) Name the file, open the file, and delete the file (B) Insert a diskette, open a file, and remove the diskette (C) Open the existing file, read/write data, close the file (D) none of these (C) Templates 106. In the template declaration, T stands for (A) an integer data type (B) a generic data type (C) an arbitrary class (D) a class defined earlier (B) 107. A function with variable number of arguments (A)has only one prototype declaration (B)should have as many as prototype declarations to be used to actual functions used with different parameters (C)does not require prototype of the function (D)none of the above (A)
Exception handling 108.An exception thrown from outside try block will ______________. (A) call function return (B) be ignored (C) hang the machine (D) call function terminate (D) 109.An exception is caused by (A)A hardware problem (B)A problem in the operating system (C)A run-time error (D)A syntax error (C) 110. In the Standard C++ the new class string is defined in (A) header file (B) namespace std (C) namespace string (D) namespace standard (B) 111. Elements of class List can be accessed _________. (A) only sequentially (B) only randomly (C) sequentially as well as randomly (D) either sequentially or randomly (A) -------------------------------------------------------112. When a function is defined inside a class, this function is called . (A) Inside function (B) Class function (C) Inline function
(D) Interior function
(C)
113. Which of the following cannot be passed to a function? (A) Reference variable (B) Arrays (C) Class objects (D) Header files (D) 114. State true of false. (i) We cannot make the function inline by defining a function outside the class. (ii) A member function can be called by using its name inside another member fun ction of the same class, this is known as nesting of member function. (A) True, True (B) True, False (C) False, True (D) False, False (C) 115. Which of the following operators could be overloaded? (A) Size of (B) + (C) += (D) :: (B) 116. Which of the following is true about the static member variable in C++. (i) It is initialized to zero when the first object of its class is created. Oth er initialization is also permitted. (ii) It is visible only within the class, but its lifetime is the entire program . (A) i-True, ii-True (B) ii-False, ii-True (C) i-True, ii-False (D) i-False, iii-False (B) 117. Which of the following keywords are used to control access to a class membe r? (A) default (B) break (C) protected (D) goto (C) 118. What will be the values of x, m and n after execution of the following stat ements? Int x, m, n; m=10; n=15; x= ++m + n++; (A) (B) (C) (D)
x=25, x=27, x=26, x=27,
m=10, m=10, m=11, m=11,
n=15 n=15 n=16 n=16
(C)
119. The major goal of inheritance in C++ is (A) To facilitate the conversion of data types (B) To help modular programming (C) To facilitate the re usability of code (D) To extend the capabilities of a class
(C)
120. A variable is defined within a block in a body of a function. Which of the following are true? (A) It is visible throughout the function. (B) It is visible from the point of definition to the end of the program. (C) It is visible from the point of definition to the end of the block. (D) It is visible throughout the block. (D) 121. The friend functions are used in situations where (A) We want to exchange data between classes (B) We want to have access to unrelated classes (C) Dynamic binding is required
(D) We want to create versatile overloaded operators. (A) --------------------------------------------------------------------------122. What do vectors represent? (A) Static arrays (b) Dynamic arrays (c) Stack (d) Queue (B) 123. In which type of storage location does the vector members are stored? (A) Contiguous storage locations (b) Non-contiguous storage locations (c) Both a & b (d) None of the mentioned (A) 124. How many vector container properties are there in c++? A) 1 B) 2 C) 3 D) 4 (C) 125. What is the output of this program? #include #include using namespace std; int main () { unsigned int i; vector first; vector second (4, 100); vector third (second.begin(), second.end()); vector fourth (third); int myints[] = {16, 2, 77, 29}; vector fifth (myints, myints + sizeof(myints) / sizeof(int) ); for (vector :: iterator it = fifth.begin(); it != fifth.end (); ++it) cout << ' ' << *it; return 0; } A) 16 B) 16 2 C) 16 2 77 D) 16 2 77 29 (D) 126. What is the output of this program? #include #include int main () { vector myvector; int sum (0); myvector.push_back (100); myvector.push_back (200); myvector.push_back (300); while (!myvector.empty()) { sum += myvector.back(); myvector.pop_back(); } cout << sum << '\n';
return 0; } A) B) C) D)
500 600 700 Error
(B)
127. What is the output of this program? #include #include using namespace std; int main () { vector a (3, 0); vector b (5, 0); b = a; a = vector(); cout << "Size of a " << int(a.size()) << '\n'; cout << "Size of b " << int(b.size()) << '\n'; return 0; } A) Size of a 0 Size of b 3 B) Size of a 3 Size of b 5 C) Error D) None of the mentioned (A) 128. What is the output of this program? Ads not by this site #include #include using namespace std; int main () { vector first; first.assign (7,100); vector::iterator it; it=first.begin()+1; int myints[] = {1776,7,4}; cout << int (first.size()) << '\n'; return 0; } A) 10 B) 9 C) 8 D) 7 (D) 129. What is the output of this program? #include #include using namespace std; int main () { vector myvector (5); int* p = myvector.data(); *p = 10; ++p; *p = 20; p[2] = 100;
for (unsigned i = 0; i < myvector.size(); ++i) cout << ' ' << myvector[i]; return 0; A) B) C) D)
10 10 10 10
} 20 0 100 0 20 0 100 20 0 20
(A)
130. Pick out the correct statement about vector. A) vector values (5) B) vector values (5) C) vector (5) D) None of the mentioned (A) 131. Which is optional in the declaration of vector? A) Type B) Name C) Vector D) Number_of_elements (D) --------------------------------------------------------------------132. Each pass through a loop is called a/an (A) enumeration (B) iteration (C) culmination (D) pass through (B) 133. Which looping process checks the test condition at the end of the loop? (A) for (B) while (C) do-while (D) no looping process checks the test condition at the end (C) 134. A continue statement causes execution to skip to (A) the return 0; statement (B) the first statement after the loop (C) the statement following the continue statement (D) the next iteration of the loop (D) 135. In a group of nested loops, which loop is executed the most number of time s? (A) the outermost loop (B) the innermost loop (C) all loops are executed the same number of times (D) cannot be determined without knowing the size of the loops (B) 136. The statement i++; is equivalent to (A) i = i + i; (B) i = i + 1; (C) i = i - 1; (D) i --; (B) 137. Which looping process is best used when the number of iterations is known? (A) for (B) while (C) do-while (D) all looping processes require that the iterations be known (A) 138. What's wrong? for (int k = 2, k <=12, k++) (A) the increment should always be ++k (B) the variable must always be the letter i when using a for loop (C) there should be a semicolon at the end of the statement (D) the commas should be semicolons (D)
139.
What's wrong? while( (i < 10) && (i > 24)) (A) the logical operator && cannot be used in a test condition (B) the while loop is an exit-condition loop (C) the test condition is always false (D) the test condition is always true
(C)
140. If there is more than one statement in the block of a for loop, which of t he following must be placed at the beginning and the ending of the loop block? (A) parentheses ( ) (B) braces { } (C) brackets [ ] (D) arrows < > (B) 141. What's wrong? (x = 4 && y = 5) ? (a = 5) ; (b = 6); (A) the question mark should be an equal sign (B) the first semicolon should be a colon (C) there are too many variables in the statement (D) the conditional operator is only used with apstrings (B) 142. The address of a variable temp of type float is (A) *temp (B) &temp (C) float& temp (D) float temp& 143. What is the output of the following code char symbol[3]={`a',`b',`c'}; for (int index=0; index<3; index++) cout << symbol [index]; (A) a b c (B) ªabcº(C) abc (D) `abc'
(B)
(C)
144. The process of building new classes from existing one is called ______. (A) Polymorphism (B) Structure(C) Inheritance (D) Cascading (C) 145. If a class C is derived from class B, which is derived from class A, all th rough public inheritance, then a class C member function can access (A) protected and public data only in C and B. (B) protected and public data only in C. (C) private data in A and B. (D) protected data in A and B. (D) 146. If the variable count (A) if (count<100) cout << (B) if (count>100) cout >> (C) if (count>100) cout << (D) None of these.
exceeds 100, a single statement that prints ªToo manyº is ªToo manyº; ªToo manyº; ªToo manyº; (C)
147. Usually a pure virtual function (A) has complete function body. (B) will never be called. (C) will be called only to delete an object. (D) is defined only in derived class.
(D)
148. To perform stream I/O with disk files in C++, you should (A) open and close files as in procedural languages. (B) use classes derived from ios. (C) use C language library functions to read and write data. (D) include the IOSTREAM.H header file.
(B)
149. Overloading the function operator (A) requires a class with an overloaded operator. (B) requires a class with an overloaded [ ] operator. (C) allows you to create objects that act syntactically like functions.
(D) usually make use of a constructor that takes arguments.
(A)
150. In C++, the range of signed integer type variable is ________ (A) 0 to 216 (B) 2 to 2 1 15 15 - - (C) 2 to 2 1 7 7 -- (D) 8 0 to 2 151. If x 5, y 2 then x y equals________. (where is a bitwise XOR operator) (A) 00000111 (B) 10000010 (C) 10100000 (D) 11001000
(A)
152. If an array is declared as int a[4] = {3, 0, 1, 2}, then values assigned to a[0] & a[4] will be ________ (A) 3, 2 (B) 0, 2 (C) 3, 0 (D) 0, 4 (C) 153. Mechanism of deriving a class from another derived class is known as____ (A) Polymorphism (B) Single Inheritance (C) Multilevel Inheritance (D) Message Passing (C) 154. RunTime Polymorphism is achieved by ______ (A) friend function (B) virtual function (C) operator overloading (D) function overloading
(B)
155. A function call mechanism that passes arguments to a function by passing a copy of the values of the arguments is __________ (A) call by name (B) call by value (C) call by reference (D) call by value result (B) 156. In C++, dynamic memory allocation is accomplished with the operator ____ (A) new (B) this (C) malloc( ) (D) delete (A) 157. If we create a file by `ifstream', then the default mode of the file is _______ __ (A) ios :: out (B) ios :: in (C) ios :: app (D) ios :: binary Ans: B 158. A variable defined within a (A) from the point of definition (B) from the point of definition (C) from the point of definition (D) throughout the function. Ans: C
block is visible onward in the program. onward in the function. onward in the block.
159. The break statement causes an exit (A) from the innermost loop only. (B) only from the innermost switch. (C) from all loops & switches. (D) from the innermost loop or switch. Ans: D 160. Which of the following cannot be legitimately passed to a function (A) A constant. (B) A variable. (C) A structure. (D) A header file. Ans: D 161. A property which is not true for classes is that they (A) are removed from memory when not in use. (B) permit data to be hidden from other classes. (C) bring together all aspects of an entity in one place. (D) Can closely model objects in the real world. Ans: C
(B)
162. You can read input that consists of multiple lines of text using (A) the normal cout << combination. (B) the cin.get( ) function with one argument. (C) the cin.get( ) function with two arguments. (D) the cin.get( ) function with three arguments. Ans: C 163. The keyword friend does not appear in (A) the class allowing access to another class. (B) the class desiring access to another class. (C) the private section of a class. (D) the public section of a class. Ans: C 164. The process of building new classes from existing one is called (A) Structure. (B) Inheritance. (C) Polymorphism. (D) Template. Ans: B 165. If you wanted to sort many large objects or structures, it would be most ef ficient to (A) place them in an array & sort the array. (B) place pointers to them in an array & sort the array. (C) place them in a linked list and sort the linked list. (D) place references to them in an array and sort the array. Ans: C 166. Which statement gets affected when i++ is changed to ++i? (A) i = 20; i++; (B) for (i = 0; i<20; i++) { } (C) a = i++; (D) while (i++ = 20) cout <
171. Additional information sent when an exception is thrown may be placed in (A) the throw keyword. (B) the function that caused the error. (C) the catch block. (D) an object of the exception class. Ans: C 172. Use of virtual functions implies (A) overloading. (B) overriding. (C) static binding. (D) dynamic binding. Ans: D 173. this pointer (A) implicitly points to an object. (B) can be explicitly used in a class. (C) can be used to return an object. (D) All of the above. Ans: D 174. Within a switch statement (A) Continue can be used but Break cannot be used (B) Continue cannot be used but Break can be used (C) Both Continue and Break can be used (D) Neither Continue nor Break can be used Ans:B 175. Data members which are static (A) cannot be assigned a value (B) can only be used in static functions (C) cannot be defined in a Union (D) can be accessed outside the class Ans:B 176. Which of the following is false for cin? (A) It represents standard input. (B) It is an object of istream class. (C) It is a class of which stream is an object. (D) Using cin the data can be read from user's terminal. Ans:C 177. It is possible to declare as a friend (A) a member function (B) a global function (C) a class (D) all of the above Ans:D 178. In multiple inheritance (A) the base classes must have only default constructors (B) cannot have virtual functions (C) can include virtual classes (D) None of the above. Ans:C 179. Declaration of a pointer reserves memory space (A) for the object. (B) for the pointer. (C) both for the object and the pointer. (D) none of these. Ans:B
180. for (; ;) (A) means the test which is done using some expression is always true (B) is not valid (C) will loop forever (D) should be written as for( ) Ans:C 181. The operator << when overloaded in a class (A) must be a member function (B) must be a non member function (C) can be both (A) & (B) above (D) cannot be overloaded Ans:C 182. A virtual class is the same as (A) an abstract class (B) a class with a virtual function (C) a base class (D) none of the above. Ans:D 183. Identify the operator that is NOT used with pointers (A) > (B) & (C) * (D) >> Ans:D 184. Consider the following statements char *ptr; ptr = ªhelloº; cout << *ptr; What will be printed? (A) first letter (B) entire string (C) it is a syntax error (D) last letter Ans:A 185. In which case is it mandatory to provide a destructor in a class? (A) Almost in every class (B) Class for which two or more than two objects will be created (C) Class for which copy constructor is defined (D) Class whose objects will be created dynamically Ans:D 186. The members of a class, by default, are (A) public (B) protected (C) private (D) mandatory to specify Ans:C 187. Given a class named Book, which of the following is not a valid constructor ? (A) Book ( ) { } (B) Book ( Book b) { } (C) Book ( Book &b) { } (D) Book (char* author, char* title) { } Ans:B 188. Which of the statements is true in a protected derivation of a derived clas s from a base class? (A) Private members of the base class become protected members of the derived cl ass (B) Protected members of the base class become public members of the derived cla ss (C) Public members of the base class become protected members of the derived cla ss (D) Protected derivation does not affect private and protected members of the de rived class.
Ans:C 189. Which of the following statements is NOT valid about operator overloading? (A) Only existing operators can be overloaded. (B) Overloaded operator must have at least one operand of its class type. (C) The overloaded operators follow the syntax rules of the original operator. (D) none of the above. Ans:D 190. Exception handling is targeted at (A) Run time error (B) Compile time error (C) Logical error (D) All of the above. Ans:A 191. A pointer to the base class can hold address of (A) only base class object (B) only derived class object (C) base class object as well as derived class object (D) None of the above Ans:C 192. Function templates can accept (A) any type of parameters (B) only one parameter (C) only parameters of the basic type (D) only parameters of the derived type Ans:C 193. How many constructors can a class have? (A) 0 (B) 1 (C) 2 (D) any number Ans:D 194. The new operator (A) returns a pointer to the variable (B) creates a variable called new (C) obtains memory for a new variable (D) tells how much memory is available Ans:C 195. Consider the following statements: int x = 22,y=15; x = (x>y) ? (x+y) : (x y); What will be the value of x after executing these statements? (A) 22 (B) 37 (C) 7 (D) Error. Cannot be executed Ans:B 196. An exception is caused by (A) a hardware problem (B) a problem in the operating system (C) a syntax error (D) a run time error Ans:D 197. A template class (A) is designed to be stored in different containers (B) works with different data types (C) generates objects which must be identical (D) generates classes with different numbers of member functions. Ans:B
198. Which of the following is the valid class declaration header for the derive d class d with base classes b1 and b2? (A) class d : public b1, public b2 (B) class d : class b1, class b2 (C) class d : public b1, b2 (D) class d : b1, b2 Ans:A 199. A library function exit() causes an exit from (A) the loop in which it occurs (B) the block in which it occurs (C) the function in which it occurs (D) the program in which it occurs Ans:D 200. RunTime polymorphism is achieved by ___________ (A) friend function (B) virtual function (C) operator overloading (D) function overloading Ans:B 201. Declaration of a pointer reserves memory space (A) for the object. (B) for the pointer. (C) both for the object and the pointer. (D) none of these. Ans:B 202. An array element is accessed using (A) a FIFO approach (B) an index number (C) the operator (D) a member name Ans:B 203. If there is a pointer p to object of a base class and it contains the addre ss of an object of a derived class and both classes contain a virtual member function abc(), then the statement p >abc(); will cause the version of abc() in the __________class to be executed. (A) Base Class (B) Derived class (C) Produces compile time error (D) produces runtime error Ans:B 204. A pure virtual function is a virtual function that (A) has no body (B) returns nothing (C) is used in base class (D) both (A) and (C) Ans:D 205. A static function (A) should be called when an object is destroyed. (B) is closely connected with and individual object of a class. (C) can be called using the class name and function name. (D) is used when a dummy object must be created. Ans:C 206. We can output text to an object of class ostream using the insertion operat or<< because (A) the ostream class is a stream (B) the insertion operator works with all classes. (C) we are actually outputting to cout. (D) the insertion operator is overloaded in ostream. Ans:D 207. The statement f1.write((char*)&obj1, sizeof(obj1)); (A) writes the member function of obj1 to f1.
(B) Writes the data in obj1 to f1. (C) Writes the member function and the data of obj1 to f1. (D) Writes the address of obj1 to f1. Ans:B 208. To convert from a user defined class to a basic type, you would most likely use. (A) A built in conversion function. (B) A one argument constructor. (C) A conversion function that's a member of the class. (D) An overloaded `=` operator. Ans:C 209. Which of the following is not the characteristic of constructor. (A) They should be declared in the public section. (B) They do not have return type. (C) They can not be inherited. (D) They can be virtual. Ans:D 210. Name the header file to be included for the use of built in function isalnu m() (A) string.h (B) process.h (C) ctype.h (D) dos.h Ans:C 211. What is the output of given code fragment? int f=1, i=2; while(++i<5) f*=i; cout<
Ans:C 216. Consider the following class definitions: class a { }; class b: protected a { }; What happens when we try to compile this class? (A) Will not compile because class body of a is not defined. (B) Will not compile because class body of b is not defined. (C) Will not compile because class a is not public inherited. (D) Will compile successfully. Ans:D 217. Which of the following expressions is illegal? (A) 10 6. (B) (false && true) (C) bool (x) = (bool)10; (D) float y = 12.67; Ans:C 218. The actual source code for implementing a template function is created when (A) The declaration of function appears. (B) The function is invoked. (C) The definition of the function appears. (D) None of the above. Ans:B 219. An exception is caused by (A) a runtime error. (B) a syntax error. (C) a problem in the operating system. (D)a hardware problem. Ans:A 220. Which of the following statements are true in c++? (A) Classes can not have data as public members. (B) Structures can not have functions as members. (C) Class members are public by default. (D)None of these. Ans:B 221. What would be the output of the following program? int main() { int x,y=10,z=10; x = (y = =z); cout<
(B) Function print() should be declared as static. (C) Function print() should be defined. (D) Class t should contain data members. Ans:A 223. What will be the output of following program? #include void main() { float x; x=(float)9/2; cout< void main() { char *ptr=ªabcdº char ch; ch = ++*ptr++; cout<
(A) continues (B) Continues . (C) Acts like (D) Acts like Ans:B
to act like a derived class object. to act like a derived class object if virtual functions are called a base class object. a base class, if virtual functions are called.
231. Which of the following declarations are illegal? (A) void *ptr; (B) char *str = ªhelloº; (C) char str = ªhelloº; (D) const *int p1; Ans:C 232. What will be the result of the expression 13 & 25? (A) 38 (B) 25 (C) 9 (D) 12 Ans:C 233. Which of the following operator can be overloaded through friend function? (A) > (B) = (C) ( ) (D) * Ans:D 234. To access the public function fbase() in the base class, a statement in a d erived class function fder() uses the statement.fbase(); (A) fbase(); (B) fder(); (C) base::fbase(); (D) der::fder(); Ans:A 235. If a base (A) It can not (B) It can not (C) It can not (D) Destructor r to the base class. Ans:D
class destructor is not virtual, then have a function body. be called. be called when accessed from pointer. in derived class can not be called when accessed through a pointe
236. Maximum number of template arguments in a function template is (A) one (B) two (C) three (D) many Ans:D 237. In access control in a protected derivation, visibility modes will change a s follows: (A) private, public and protected become protected (B) only public becomes protected. (C) public and protected become protected. (D) only private becomes protected. Ans:C 238. Which of the following statement is valid? (A) We can create new C++ operators. (B) We can change the precedence of the C++ operators.
(C) We can change the associativity of the C++ operators. (D) We can not change operator templates. Ans:D 239. What will be the output of the following program? #include void main() { float x=5,y=2; int result; result=x % y; cout<
247. What does STL stand for? A. Simple Template Library B. Standard Template Library C. Static Type Library D. Single Type based Library (B) 248. Which of the following is the most common way of implementingC++? A. C++ programs are directly compiled into native code by a compiler B. C++ programs are first compiled to intermediate code by a compiler and then e xecuted by a virtual machine C. C++ programs are interpreted by an interpreter D. A C++ editor directly compiles and executes the program (A) 249. What is the implicit pointer that is passed as the first argument for nonst atic member functions? A. `self' pointer B. std::auto_ptr pointer C. `Myself' pointer D. `this' pointer (D) 250. If X is the name of the class, what is the correct way to declare copy cons tructor of X? A. X(X arg) B. X(X* arg) C. X(const X* arg) D. X(const X& arg) (D) 251. Which of the following operator cannot be overloaded? A. = (assignment operator) B. == (equality operator) C. ±> (rrow operator) D. :: (cope resolution operator) (D) 252. Which of the following operators can be overloaded? A. . (dot or member access operator) B. & (address of operator) C. sizeof operator D. ?: (conditional operator) (B) 253. How do we declare an abstract class? A. By providing at least one pure virtual method (function signature followed by ==0;) in a class B. By declaring at least one method abstract using the keyword `abstract' in a class C. By declaring the class abstract with the keyword `abstract' D. It is not possible to create abstract classes in C++ (A) 254. How do we declare an `interface' class?
A. By B. By C. By D. It (A)
making all the methods pure virtual in a class making all the methods abstract using the keyword `abstract' in a class declaring the class as interface with the keyword `interface' is not possible to create interface class in C++
255. How many copies of a class static member are shared between objects of the class? A. A copy of the static member is shared by all objects of a class B. A copy is created only when at least one object is created from that class C. A copy of the static member is created for each instntiation of the class D. No memory is allocated for static members of a class (A) 256. Which of the following is true about const member functions? A. const members can be invoked on both const as well as nonconst objects B. const members can be invoked only on const objects and not on nonconst object s C. nonconst members can be invoked on const objects as well as nonconst objects D. none of the above (A) 257. When is std::bad_alloc exception thrown? A. When new operator cannot allocate memory B. When alloc function fails C. When type requested for new operation is considered bad, thisexception is thr own D. When delete operator cannot delete teh allocated (corrupted) object (A) 258. Which header file should we include for using std::auto_ptr? a. B. C. D. (C) 259. STL is based on which of the following programming paradigms? A. Structured Programming B. Object Oriented Programming (OOP) C. Functional Programming D. Aspect Oriented Programming (AOP) (C) 260. Which of n C++? A. Namespaces B. Namespaces C. Namespaces D. namespaces name clashes (D)
the following correctly describes the meaning of `namespace' feature i refer to the memory space allocated for names used in a program refer to space between teh names in a program refer to space between the names in a program provide facilities for organizing the names in a program to avoid
261. Which of the following is the most general exception handler that catches e xception of any type?
A. catch(std::exception) B. catch(std::any_exception) C. catch(¼) D. catch() (C) 262. STL is based on which of the following programmingparadigms? a. Structured Programming b. Object Oriented Programming (OOP) c. Functional Programming d. Aspect Oriented Programming (AOP) (C) 263. Which of C++? a. Namespaces b. Namespaces c. Namespaces d. Namespaces ame clashes. (D)
the following correctly describes the meaning of`namespace' feature in refer to the memory space allocated for names used in a program refer to space between the names in a program refer to packing structure of classes in a program. provide facilities for organizing the names in aprogram to avoid n
264. Which of the following is the most general exception handler that catches e xception of `any type'? a. catch(std::exception) b. catch(std::any_exception) c. catch(¼) d. catch() (C) 265. Which of the following relationship is known as inheritancerelationship? a. `has a' relationship b. `is a' relationship c. association relationship d. none of the above (B) 266. Which of the following operators can be implemented as a nonmember operator ? a. = (assignment operator) b. () (function call operator) c. [] (array access operator) d. + (addition operator) (D) 267. Which of the STL containers store the elements contiguously (in adjecent me mory locations)? a. std::vector b. std::list c. std::map d. std::set (A) 268. Which of the following is not recommended in a header file? a. Type definitions (typedefs) b. Class definitions c. Function definitions d. Template definitions (C)
269. If the class name is X, what is the type of its ªthisº pointer (in a nonstatic, non const member function)? a. const X* const b. X* const c. X* d. X& (B) 270. Which of the following is the most preferred way of throwing and handling e xceptions? a. Throw by value and catch by reference. b. Throw by reference and catch by reference. c. Throw by value and catch by value d. Throw the pointer value and provide catch for teh pointer type. (A) 271. If class A is friend of class B and if class B is friend of class C, which of the following is true? a. Class C is friend of class A b. Class A is friend of class C c. Class A and Class C do not have any friend relationship d. None of the above (C) 272. The conditional compilation a. It is taken care of by the compiler b. It is setting the compiler option conditionally c. It is compiling a program based on a condition d. none of above (C) 273. Originally `C' was developed as: a. System programming language b. General purpose language c. Data processing language d. None of above (B) 274. Minimum number of temporary variagble needed to swap the contents of 2 vari able is: a. 1 b. 2 c. 3 d. 0 (D) 275. A direct access file is: a. A file in which recoreds are arranged in a way they are inserted in a file b. A file in which records are arranged in a particular order c. Files which are stored on a direct access storage medium d. None of the above (C)
276. Which of the following is not an advantage of secondary memory
a. It b. It c. It d. It (C)
is cost effective has large storage capacity has highest speed is easily portable
277. An inverted file a. Locates information about data in small files that are maintained apart from actual data record b. A file which stores opposite records c. A file which stores information about records of a system d. None of above (A) 278. Which of the following is not a file operation: a. Repositioning b. Truncating c. Appending d. None of above (D) 279. Which of the following is not a component of file system a. Access method b. Auxiliary storage management c. Free integrity mechanism d. None of the above (D) 280. Seek time is a. time taken to retrieve a dta b. Time taken by read/write head mechanism to position itself over appropriate c ylinder c. Time taken by appropriate sector to come under read/write d. None of the above (B) 281. Latency time is: a. Time taken by read/write head mechanism to position itself over appropriate c ylinder b. Time taken to transfer a dta from memory c. Time taken by appropriate sector to come under read/write head d. None of above (C) 282. `Prime area' in context of file system is defined as a. It is memory area created by operating system b. It is an area into which data records are written c. It is the main area of a web page d. None of the above (B) 283. The two types of file structure existing in VSAM file are a. Key sequenced structure, entry sequenced structure
b. Key sequence structure, exit sequenced structure c. Entry sequence structure, exit sequenced structure d. None of above (C) 284. In mulit list organization a. Records that have equivalent value for a given secondary index item are linke d together to form a list. b. Records are loaded in ordered sequence defined by collating sequence by conte nt of the key c. Records are directly accessed by record key field d. None of the above (A)
285. Which of the following is/are advantages of cellular partitioned structure: a. Simultaneous read operations can be overlapped b. Search time is reduced c. Both a & b d. None of the above (C)
286. *ptr++ is equivalenet to: a. ptr++ b. *ptr c. ++*ptr d. None of the above (D) 287. Statement scanf(ª%dº,80); a. Assign an integer to variable i b. Give an error message c. Print the value of i d. Assign an float to variable i (A) 288. Value of ix+j, if i,j are integer type and ix long type would be a. integer b. float c. long integer d. double percision (C) 289. In a C language `3' represents a. A digit b. An integer c. A character d. A word (C) 290. In C language, a hexadecimal number is represented by writing a. x b. xo c. ox
d. h (D) 291. Expression C=i++ causes a. Value of i assigned to C and then i incremented by 1 b. i to be incremented by 1 and then value of i assigned to C c. Value of i assigned to C d. i to be incremented by 1 (A) 292. In an assignment statement a=b; Which of the following statement is true? a. The variable a and the variable b are equal. b. The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a c. The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a d. The value of variable a is assigned to variable b and the value of variabl e b is assigned to variable a.b (B) 293. All of the following are valid expressions in C++ a = 2 + (b = 5); a = b = c = 5; a = 11 % 3 a. True b. False (A) 294. To increase the value of c by one which of the following statement is wrong ? a. c++; b. c = c + 1; c. c + 1 => c; d. c += 1 (C) 295. When following piece of code b = 3; a = b++; a. a contains 3 and b contains b. a contains 4 and b contains c. a contains 4 and b contains d. a contains 3 and b contains (A)
is executed, what happens? 4 4 3 3
296. The result of a Relational operation is always a. either True or False b. is less than or is more than c. is equal or less or more d. All of these (A) 297. Which of the following is not a valid relational operator? a. == b. => c. >= d. >= (B)
298. What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run? A. 10 B. 9 C. 0 D. 1 (A) 299. When does the code block following while(x<100) execute? A. When x is less than one hundred B. When x is greater than one hundred C. When x is equal to one hundred D. While it wishes (A) 300. Which is not a loop structure? A. for B. do while C. while D. repeat until (D) 301. How many times is a do while loop guaranteed to loop? A. 0 B. Infinitely C. 1 D. Variable (C) 302. Find out the error in following block of code. If (x = 100) Cout << ªx is 100º; a. 100 should be enclosed in quotations b. There is no semicolon at the end of first line c. Equals to operator mistake d. Variable x should not be inside quotation (C) 303. Looping in a program means a. Jumping to the specified branch of program b. Repeat the specified lines of code c. Both of above d. None of above (B) 304. The difference between while structure and do structure for looping is a. In while statement the condition is tested at the end of first iteratio n b. In do structure the condition is tested at the beginning of first iterat ion c. The do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not d. In while structure condition is tested before executing statements insid e loop whereas in do structure condition is tested before repeating the statemen ts inside loop (D) 305. Which of the following is not a looping statement in C? a. while
b. c. d. (B)
until do for
306. Which of the following is not a jump statement in C++? a. break b. goto c. exit d. switch (D) 307. Which of the following is selection statement in C++? a. break b. goto c. exit d. switch (D) 308. The continue statement a. resumes the program if it is hanged b. resumes the program if it was break was applied c. skips the rest of the loop in current iteration d. all of above (C) 309. Consider the following two pieces of codes and choose the best answer Code 1: switch (x) { case 1: cout <<ºx is 1º; break; case 2: cout <<ºx is 2º; break; default: cout <<ºvalue of x unknownº; } Code 2 If (x==1){ Cout <<ºx is 1º; } Else if (x==2){ Cout << ªx is 2º; } Else{ Cout <<ºvalue of x unknownº; } a. b. c. d. (A)
Both of the above code fragments have the same behaviour Both of the above code fragments produce different effects The first code produces more results than second The second code produces more results than first.
310. Observe the following block of code and determine what happens when x=2? switch (x){ case 1: case 2:
case 3: cout<< "x is 3, so jumping to third branch"; goto thirdBranch; default: cout<<"x is not within the range, so need to say Thank You!"; } a. Program jumps to the end of switch statement since there is nothing to do for x=2 b. The code inside default will run since there is no task for x=2, so, def ault task is run c. Will display x is 3, so jumping to third branch and jumps to thirdBranc h. d. None of above (C) 311. Which of the following is false for switch statement in C++? a. It uses labels instead of blocks b. we need to put break statement at the end of the group of statement of a condition c. we can put range for case such as case 1..3 d. None of above (C) 312. Which of the following regarding constructor function is false? a) Constructor functions don t have return type, not even void b) Constructors can t be inherited c) We can refer to their addresses d) Constructors cannot be virtual (c) 313. If new operator is used, then the constructor function is a) Parameterized constructor b) Copy constructor c) Dynamic constructor d) Default constructor (c) 314. Which of the following statements regarding constructor is false? a) A constructor may be defined static b) Constructor can have default arguments c) Member functions may be invoked from within a constructor d) None of the above (a) 315. The antonym of constructor is a) Creator b) Destructor c) Destroyer d) None of the above (b) 316. Variable .............. of void type a) May be declared b) Cannot be declared c) Can be initialized d) None of the above (b)
317. A destruction function a) Takes no argument and has no return type not even void b) Has name similar to that of class, preceded by tilde(~) symbol c) Is used to destruct an object, constructed through constructor function d) All of the above (d) 318. Which of the following statements regarding destructor function is false? a) Destructors do not accept any arguments, nor do they return any values b) Destructors can be inherited c) Member functions may be called from within a destructor d) Destructor functions are called automatically when an object is destroyed (b) 319. Function overloading a) Involves several function definitions under one name, but different argument types b) Implements polymorphism c) Reduces the number of comparison in a program, hence increases the execution speed of a program d) All of the above (d) 320. The signature of function is a) The number & type of arguments b) The return type of a function c) The class definitiond) None of the above (a) 321. 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 (b) 322. The binding of a function call at runtime is a) Static binding b) Early binding c) Late binding d) Runtime binding (c) 323. The process of giving special meaning to an operator is a) Operator overloading b) Operator mechanism c) Operator definition d) None of the above (a) 324. The function used to define the task assigned to an operator is a) Virtual function b) Operator function c) Static function d) None of the above (b) 325. The following operators can not be overloaded a) Unary operator b) Binary operator
c) Ternary operator d) None of the above (c) 326. Which of the following statements regarding operator overloading is not tru e? a) New operators cannot be created while overloading b) The semantics of an operator cannot be changed while overloading c) Subscript operator([]) can be overloaded d) None of the above (d) 327. Which of the following statements can be overloaded? a) Size of operator b) Scope resolution operator (::) c) Class member access operator ( >) d) Pointer to member operator (c) 328. Operator functions a) Can return a value b) Cannot return a value c) May return values of limited data types d) None of the above (a) 329. While overloading, a unary operator a) Takes no arguments b) Takes one argument c) Takes two arguments d) None of the above (a) 330. While overloading, a binary operator a) takes no argument b) takes one argument c) takes two arguments d) none of the above (b) 331. Which of the following operators cannot be overloaded? a) increment and decrement operator b) function call operator, () c) subscript operator, [] d) none of the above (d) 332. When an arithmetic assignment operator is overloaded, the result a) goes in the object to the left of the operator b) goes in the object to the right of the operator c) goes in the object of which the operator is amember d) none of the above (a) 333. The function that overloads as operator, precedes with the keyword a) function b) operator c) virtual d) static (b)
334. The symbol ** a) can be overloaded b) cannot be overloaded as it is not a C++ operator c) cannot be overloaded, as on overloading its meaning shall be changed d) none of the above (b) 335. The stream insertion and extraction operators should be overloaded as a) friend functions b) member function c) non member functions d) none of the above (a) 336. The following operators cannot be overloaded a) scope resolution operator b) size of operator c) conditional operator d) all of the above (d) 337. The operator definition precedes with the keyword class a) class b) operator c) overload d) none of the above (b) 338. The operator function a) is declared in the public section of the class b) may be a member function or a friend function c) both (a) & (b) d) none of the above (c) 339. The operator functions may be invoked a) implicitly b) explicitly c) both (a) & (b) d) none of the above (c) 340. The following operator can t be overloaded a) unary b) binary c) ternary d) none of the above (c) 341. Which of the following statements regarding operator overloading function i s false? a) While overloading, the semantics of an operator cannot be changed. b) The operator precedence cannot be changed while overloading. c) The overloaded operator must have at least one operand that is of user define d type. d) You can create new operator symbol. (d) 342. The following operators cannot be overloaded.
a) Logical AND (&&) b) Subscript operator ([]) c) Equality operator (==) d) none of the above (d) 343. A unary operator when overloaded takes a) no operand b) one operand c) two operands d) none of the above (b) 344. The no of arguments required when overloading through friend functions is a) Zero b) One c) Two d) None of the above (c) 345. Which of the following statements regarding operator overloading is false? a) friend function cannot be used to overload certain operators. b) Unary operators overloaded by means of friend functions takes no argument c) Binary operators must explicitly return a value d) The syntax rules of the operators cannot be overridden. (b) 346. The following feature supports extensibility and reusability of classes a) function overloading b) inheritance c) operator overloading d) data encapsulation (b) 347. The process of deriving a class from another derived class is a) single inheritance b) multilevel inheritance c) multiple inheritance d) none of the above (b) 348. When a derived class inherits only from one class and is not further inheri ted is a) single inheritance b) multiple inheritance c) multilevel inheritance d) hybrid inheritance (a) 349. When a derived class inherits from may base classes it is a) multilevel inheritance b) single inheritance c) multiple inheritance d) none of the above (c) 350. Inheritance is ......... in nature a) transitive b) intransitive c) both (a) & (b)
d) none of the above (a) 351. ............. variables cannot be declared a) structure b) pointer c) void d) class (c) 352. When a subclass inherits from multiple base classes, which inherits from a single class, the inheritance type is a) single inheritance b) hybrid inheritance c) multilevel inheritance d) multiple inheritance (b) 353. When one class inherits from the base class, then the original class is cal leda) base class b) derived class c) sub class d) none of the above (a) 354. The default visibility mode while inheriting is a) private b) public c) protected d) none of the above (d) 355. The class intended to be a base class should use visibility mode as a) public b) protected c) private d) Both (a) & (b) (d) 356. Operator a) making c++ b) giving c++ c) giving new d) making new (c)
overloading is operators work with objects operators more than they can handle meaning to existing c++ operators c++ operators
357. To convert from a user defined class to a basic type, you would most likely use a) a built in conversion function b) a one argument constructor c) an overloaded operator d) a conversion function that s member of the class (d) 358. The members of a class a) by default are public b) by default are private c) are made private by declaring as private d) none of the above (b)
359. The following symbol indicates the derived class is derived from the base c lass a) :: b) : c) > d) none of the above (b) 360. When a base class publicly inherited a) the public members of the base class are inherited as private b) the private members are inherited as private c) the protected members are inherited as protected d) none of the above (c) 361. When a base class is privately inherited by derived class a) the public members of the base class becomes the private members of the deriv ed class b) the private members are not inherited c) the protected members of the base class becomes the private members of the de rived class d) All of the above (d) 362. Only one copy of the class is inherited, when it is defined as a) virtual b) static c) public d) none of the above (a) 363. A class that acts only as a base class andis not used to create objects isa ) parent class b) super class c) abstract class d) none of the above (c) 364. The version of a virtual function actually gets called during runtime is ba sed solely up in the type of the object that is a) being instantiated and processed by the function b) in the derived class c) being pointed to by a base class pointer d) being passed to the function (c) 365. In multiple inheritance, the base classes are constructed a) in the order of declaration in the derived class b) in the order of declaration in the program. c) in the order of definition of a class d) none of the above (a) 366. When an object of a derived class is created a) derived class constructor is called followedby base class constructor b) base class constructor is called followed byderived class constructor c) base class constructor is not called at all d) none of the above (b)
367. The derived class constructor a) never passes any values to base class constructor b) is responsible for passing the entire test of arguments needed by base class constructors c) can pass arguments only to one base class constructor function d) none of the above (b) 368. A virtual base class a) allows to inherit more than one copy of the base class members b) strict the path of inheritance c) is qualified as virtual in base class definition d) none of the above (c) 369. When a base class is inherited publicly a) the private members of the base class are not accessible b) the derived class can directly access the private members of the base class c) the derived class can access the private members only through the member func tion of the base class d) none of the above (c) 370. When two or more classes are used within another class definition, it is a) inheritance b) aggregation c) both (a) & (b) d) none of the above (b) 371. Composition is referred to as a) is a relationship b) has a relationship c) both (a) & (b) d) none of the above (b) 372. Inheritance is referred to as a) is a relationship b) has a relationship c) Both (a) & (b) d) none of the above (a) 373. An explicitly defined destructor function a) may be virtual b) may not be virtual c) both (a) & (b) d) None of the above (a) 374. The copy operation by a simple assignment causes in some cases a) no effect b) hollow copy c) copy exactly the same as original d) creates new (b) 375. Public data members can be accessed
a) only b) both c) from d) none (c)
from the base class itself form the base class and from its derived class the class which is a friend of the base class of the above
376. A static automatic variable is used to a) make a variable visible to several function b) make a variable visible only to one function c) converse memory when a function is not executing d) retain a value when a function is not executing (c) 377. The stacks data structure are based on a) LIFO b) FILO c) FIFO d) None of the above (a) 378. Queues are based on a) LIFO b) FILO c) FIFO d) None of the above (c) 379. & operator is a) indirection operator b) Logical AND c) address operator d) none of the above (c) 380. int *ptr[10]; is a) an array of 10 int pointers b) a pointer of 10 int elements c) an array of 10 elements returning an int value d) none of the above (a) 381. A structure that refers to itself is a a) nested structure b) recursive structure c) self referential structure d) none of the above (c) 382. With in .............scope class member may be referenced simply by their n ames a) class s b) object s c) program d) none of the above (a) 383. To point to the address of any pointer variable cast the pointer to a) char * b) int * c) void *
d) none of the above (c) 384. Destructors are called a) in the same order of constructor calls b) in the reverse order of constructor calls c) in any random order d) none of the above (b) 385. The advantage of declaring a virtual function as pure is a) you can avoid making the class an abstract class b) you force any derived class to define its own implementation c) programs runs faster d) early binding can be achieved (b) 386. What is the final number output for the following code snippet? for (i = 1 ; i <= 20 ; i = i + 2); cout << ª ª << i ; a) 10 b) 19 c) 20 d) This is an illegal set up for loop parameters. (B) 387. What is the value of i after the following code fragment executes? int i = 2; int k = 5 ; i *= k + 1; a) 7 b) 11 c) 12 d) 14 (D) 388.Why does this code snipper give a compile error? int loopCounter = 0; int numberOfScores = 20; while (loopcounter < numberOfScores) cout << ª\nInside the loopº; a) The value of the control loop control variable does not change the loop body . b) The curly brackets are missing around the loop body. c) The loopCounter variable is not spelled consistently. d) All of the Above (D) 389. What is wrong with the following switch statement? switch(x) { case 0: cout << x; case 2: cout << 2 / x; break; default: cout << ªerrorº; break;
} a) The value of x could be something other than 1 or 2. b) There is no break statement for case 1. c) There is no semicolon after the closing bracket. d) All of the above (B) 390. If firstName and lastName are string object variables, which statement can be used to combine (append or concatenate) the two into a single string variable ? a) fullName = firstName + lastName; b) fullName = firstName, lastName; c) fullName = firstName & lastName; d) fullName = firstName && lastName; (C) 391. What is the bit pattern in data after the following statements execute? unsigned int data = 10; data = data | 0x0B; data = data << 1 a) 0x314 b) 0x154 c) 0x342 d) 0x156 (D) 392. Given the following code fragment, what is the data type of thisStudent? struct student { string name; double gpa; }; student thisStudent; a) string b) const pointer to student c) student d) double (C) 393. What is the data type of bullpen[3].era? struct pitcher { string name; double era; }; pitcher p1; pitcher bullpen[10]; a) string b) double c) pitcher d) const pointer to pitcher (D) 394. What is the declaration for a C style string that can hold a name with up to 3 printable characters (for example, ªRonº)? a) int name [3]; b) char name [3] c) int name [4]; d) char name [4]; (D)
395. Which type of error does the following code fragment cause? const int MAX = 500; int main (void) { int foo [MAX]; for (int i = 0; i <= MAX; i++) { foo [i] = i * 2; } a) Compiler, because of out of bounds array subscript b) Run time, because of out of bounds array subscript c) Compiler, because of invalid array initialization d) None of the above. It does not create any type of error. (D) 396. The function call below is designed to return, in variable result, the prod uct of x and y. All the variables are of type int. What is the correct prototype for such a function? myFunction(&result, &x, &y); a) void myFunction(int, int, int) ; b) void myFunction(int *, int *, int *) ; c) void myFunction(const int *, const int *, const int *) ; d) void myFunction(int *, const int *, const int *) ; (D) 397. The function call below is designed to return, in variable result, the prod uct of x and y. All the variables are of type int. What is the correct prototype for such a function? myFunction(result, x, y); a) void myFunction(int &, int, int) ; b) void myFunction(int, int, int) ; c) void myFunction(const int *, const int, const int) ; d) void myFunction(int *, const int *, const int *) ; (B) 398. Identify the correct prototype for a function that receives an array of dou bles, computes the sum of all the elements of the array, and returns the sum to the calling function. a) void computeSum(double array[], int size, double * sum); b) void computeSum(double array[], int size, double & sum); c) double computeSum(double array[], int size); d) All of the Above (A) 399. What is the output of the following code? void func(int x) { x = x * 2; } int main( ) { int x = 10; func(x); cout << x << endl; } a) 20 b) 30 c) 10 d) 5
(C) 400. The word const inside the parentheses of the following declaration of isEqu al bool isEqual (const Distance & rightSideObject) const; a) ensures the member variables of the called objects are protected (cannot be c hanged). b) ensures the argument passed in to the function is protected (cannot be change d). c) ensures the return value of the function is protected (cannot be changed). d) ensures the return value is routed to the proper variable. (A) 401. Which of the following is called automatically each time an object is creat ed? a) Compiler b) Builder c) Constructor d) Destructor (C) 402. Which of the following is called automatically each time an object goes out of scope? a) Compiler b) Builder c) Constructor d) Destructor (D) 403. Given the following class definition and lines of code, what, if anything, is wrong with Line 6 in main? class Distance { private: int feet; double inches; public: Distance( ); Distance(int initFt, double initIn); void setFeet(int feetIn); void setInches(double inchesIn); int getFeet() const; double getInches( ) const; }; int main( ) { Distance d1; //Line 1 const int MAX = 100; //Line 2 Distance list [MAX]; //Line 3 Distance d2(1, 2.3); //Line 4 Distance * pDist; //Line 5 d1.feet = 5; //Line 6 // etc. ± assume the remaining code is correct } a) It will not compile: feet is private and cannot be directly accessed. b) Distance d1; should be changed to int d1;. c) The ::d1.feet = 5; should be changed to d1(feet) = 5;. d) It will compile, but causes a run time error because d1.feet has not been de clared. (C)
404. Composition is typically an example of a) a ªhas aº relationship. b) an ªis aº relationship. c) a ªuses aº relationship. d) a ªis usedº relationship (A) 405. When organizing a program into three files (main, class implementation, and class header), where are user defined data types declared? a) main.cpp b) class.cpp c) class.h d) main.h (C) 406. When writing a class, the compiler automatically creates some support funct ions for the class. What are some of these functions? a) Assignment operator function b) Copy constructor c) Assignment operator and copy constructor d) None of the Above (C) 407. Assume you have to write a class that makes use of dynamic memory allocatio n (the class needs to allocate and de allocate memory). According to best practi ces, where would the keyword `new' be placed? a) Classes are smart data types. The compiler takes care of calling new/delete. b) In the constructor c) In the destructor d) In a separate, dedicated function (B) 408. What is the data type of pDist for the code snippet below? Distance * pDIST; a) Distance b) Const pointer to Distance c) Pointer to Distance d) None of the Above (B) 409. Given the definition of some class called Employee, which of the following correctly dynamically allocates an array of 20 Employee objects? a) Employee * myData = new Employee[20]; b) Employee myData[20] = new Employee[20]; c) Employee = myData[20]; d) Employee array = new Employee[20]; (a) 410. What is the output of the following code snippet? int *p; int *q; p = new int; *p = 43; q = p; *q = 52; p = new int; *p = 78; q = new int; *q = *p;
cout << *p << " " << *q << end1 a) 4352 b) 5278 c) 7878 d) 7852 (d)
411. Which allows you to create a derived class that inherits properties from mo re than one base class? A. Multilevel inheritance B. Multiple inheritance C. Hybrid Inheritance D. Hierarchical Inheritance (B) 412. Which feature in OOP allows reusing code? A) Polymorphism B) Inheritance C) Encapsulation D) Data hiding (B) 413. A function that changes the state of the cout object is called a(n) _____ A. member B. adjuster C. manipulator D. operator (C) 414. What does C++ append to the end of a string literal constant? A. a space B. a number sign (#) C. an asterisk (*) D. a null character (D) 415. An array element is accessed using A. a first in first out approach B. the dot operator C. a member name D. an index number (D) 416. To hide a data member from the program, you must declare the data member in the _____ section of the class A. concealed B. confidential C. hidden D. private E. restricted (D) 417. External documentation includes A. a printout of the program s code B. flowcharts C. IPO charts D. pseudo code E. All of the above (A) 418. The function whose prototype is void getData(Item *thing); receives A. a pointer to a structure B. a reference to a structure C. a copy of a structure D. nothing (A) 419. Null character needs a space of A. zero bytes B. one byte
C. three bytes D. four bytes
(B)
420. The number of structures than can be declared in a single statement is A. one B. two C. three D. unlimited (D) 421. Which of the following formulas can be used to generate random integers bet ween 1 and 10? A. 1 + rand() % (10 1 + 1) B. 1 + (10 1 + 1) % rand() C. 10 + rand() % (10 1 + 1) D. 10 + rand() % (10 + 1) (A) 422. Format flags may be combined using the _____ A. bitwise OR operator (|) B. logical OR operator (||) C. bitwise AND operator (&) D. logical AND operator (&&) (A) 423. Which A. counPop B. counPop C. counPop D. counPop
of the following will store the number 320000 as a Float number? = (float) 3.2e5; = (float) 3.2e6; = (float) .32e5; = (float) .32e7; (A)
424. The arguments that determine the state of the cout object are called A. classes B. manipulators C. format flags or state flags D. state controllers (C) 425. The following statement where T is true and F is false T&&T||F&&T A. is true B. is false C. is wrong D. not applicable in C language (A) 426. Which of the following statements declares a variable that can contain a de cimal number? A. dec payRate; B. dec hourlyPay C. float payRate D. float hourlyPay; (D) 427. The statement int num[2][3]={ {1,2}, {3,4}, {5, 6} }; A. assigns a value 2 to num[1][2] B. assigns a value 4 to num[1][2] C. gives an error message D. assigns a value 3 to num[1][2] (C) 428. The standard input stream, which refers to the keyboard, is called A. cin B. cout C. stin D. stout (A) 429. Elements in an array are identified by a unique _____ A. data type B. order
C. subscript D. symbol
(C)
430. The statement fwrite ( (char*)&objl, sizeof(objl) ); A. writes the member functions of objl to fl B. writes the data in objl to fl C. writes the member functions and me data of obj 1 to fl D. writes the address of objl to fl (B) 431. The body of a C++ function is surrounded by _____ A. parentheses B. angle brackets C. curly brackets D. square brackets (C) 432. Which of the following type casts will convert an Integer variable named am ount to a Double type? A. (double) amount B. (int to double) amount C. int to double(amount) D. int (amount) to double (A) 433. The loosest type of coupling is A. data coupling B. control coupling C. external coupling D. pathological coupling (A) 434. Which of the following is a string literal constant? A. ªVisual C++º B. ª137.45º C. ªAº D. ª2,365º E. All of the above (E) 435. Which of the following, if any, are valid names for variables? A. class B. friend C. #OnHand D. void E. None of the above is valid names for variables (E) 436. You have assigned the address of Value to the pointer P, Which statement wi ll display the value stored in Value? A. cout<