1. What does OOD stand for?
2. What is output of following program? #include <iostream> int main() { double x = 1.0; for(int i = 0; i < 3; ++i) x *= 0.1; std::cout << x * 1e3 - 1; }
3. struct A { int n; }; A a; What is the visibility of a.n?
4. std::make_heap() converts a range into a heap and std::sort_heap() turns a heap into a sorted sequence.
5. If you have two different C++ functions which have the same name but different parameter types, it is called...
6. Which is a valid variable declaration statement?
7. C++ statements are separated by this symbol:
8. Which is a valid C++ function declaration which does not return a value?
9. How do you declare an integer variable x in C++?
10. Which is not a loop structure?
11. Which is not a fundamental data type in C++?
12. Which operators below allow you to define the member functions of a class outside the class?
13. Which of the following is not a C++ primitive type?
14. Which of the following statements tests to see if the sum is equal to 10 and the total is less than 20, and if so, prints the text string 'incorrect.'?
15. Choose the function declaration which you would use if you did not need to return any value.
16. Which is a reserved word in C++?
17. Which statement assigns to variable a the address of variable b?
18. Which is a valid comment statement in C++?
19. A void pointer is a special type of pointer which indicates the absence of a type for the pointer.
20. What does the following statement mean? const int a = 50;
21. In C++, a single line comment needs to be begun with
22. What is the value of i after the following statement(s)? int i (4.36);
23. In the following line of C++ code, int foo[50]; what does the number 50 represent?
24. The printmsg function does not require any arguments. Choose the statement which calls the function.
25. Can constructors be overloaded?
26. What is an advantage to using C++ Templates?
27. Which is(are) an example(s) of valid C++ function prototype(s)?
28. Classes can contain static member variables which are global to the class and...
29. What does the sizeof(arg) operator do?
30. What is the difference between a class and a struct
31. In C++, a comment can only be specified with a leading //.
32. std::vector<int> v(4); std::fill(v.begin(), v.end(), 4); What is the content of vector v?
33. What will 'int a = 'a';' do?
34. Which of the following can cause a memory corruption error?
35. Consider this code fragment: a = 25; b = &a; What does b equal?
36. Which is not a specific type casting operator in the C++ language?
37. A structure item exists in your code with an integer member units. You have the following variable declaration: item * myItem;. How do you access the value of units?
38. Defined data types (typedef) allow you to create...
39. Which of the following is a valid variable identifier in C++?
40. What does the line: #include <iostream> mean in a C++ program?
41. Output of the given code? #include struct shape { virtual void move() { std::cout << 'shape::move\n'; } }; struct circle : public shape { void move() { std::cout << 'circle::move\n'; } }; struct rectangle : public shape { void move() { std::cout << 'rectangle::move\n'; } }; int main() { shape *s; s = new shape(); s->move(); s = new circle(); s->move(); s = new rectangle(); s->move(); return 0; }
42. Within a class declaration, the statement 'virtual int foo() = 0;' does what?
43. std::vector<int> foo(5);
44. Where does the compiler first look for file.h in the following directive: #include 'file.h' ?
45. What is the value of 2--2?
46. True or False: A class that has a pure virtual method can be instantiated.
47. Define a way other than using the keyword inline to make a function inline
48. Difference between struct and class types?
49. What is the size of the character array which would hold the value 'Helloo'?
50. In C++, what is the difference between these two declarations: void foo(); void foo(void);
51. Which rules apply to operator overloading in C++?
52. Which class(es) can be used to perform both input and output on files in C++?
53. What is the data type for the following: L'Hello World'?
54. Thinking about data members and addressable memory, how are a struct, class and union different?
55. Which C++ keyword allows the compiler to determine the type of a variable by the value used to initialized it?
56. int *array = new int[10]; delete array;
57. What does the 'explicit' keyword do?
58. What is a virtual function in C++?
59. What is the time complexity of delete the first variable in a deque object (e.g., deque<int> a;)?
60. Suppose int * a = new int[3]; How would you deallocate the memory block pointed by a?
61. Which operator cannot be overloaded by a class member function?
62. Which of the following statements uses a Lambda expression?
63. A void pointer is a special type of pointer which indicates the...
64. Which calls method foo() from the parent class Parent of the current class?
65. An anonymous namespace is used to...
66. Is the following legal C++ code? | char *str = 'abc' + 'def';
67. What is the data range for an unsigned integer value in C++ on a system where ints are 32 bits?
68. How would you access 'blue' in the 'color' enum class? enum class color { red, blue, green };
69. String literals can extend to more than a single line of code by putting which character at the end of each unfinished line?
70. Which of the following is a potential side-effect of inlining functions?
71. What type of exceptions can the following function throw: int myfunction (int a);?
72. Which one is theorically faster ?
73. Value of x after the following code: int x = 0; if (x = 1) { x = 2; } else { x = 1; }
74. What is the value of 10.10 % 3?
75. class A { int x; protected: int y; public: int z; }; class B: private A { }; What is the privacy level of B::z?
76. If you do not supply any constructors for your class, which constructor(s) will be created by the compiler?
77. Key difference between a struct and union in terms of memory size?
78. Given: union a { int x; short y; }; a var[20]; How many bytes of memory does var occupy?
79. What is the output of the following code? int a=8; for(int i=1; i<=i*3; i++) n++;
80. Will the code below compile without error? struct c0 { int i; c0(int x) { i = x; } }; int main() { c0 x1(1); c0 x2(x1); return 0; }
81. Which is NOT a valid hash table provided by the STL?
82. Where T is a type: std::vector<T>::at vs std::vector<T>::operator[]:
83. enum { a, b, c = b + 2 }; What is the value of c?
84. What is the type being defined here: typedef A (B::*C)(D, E) const;
85. std::tuple person{'John Doe', 42}; std::cout << std::get<1>(person); What is the output?
86. What is the below code? struct code { unsigned int x: 4; unsigned int y: 4; };
87. What is the guaranteed complexity of std::push_heap?
88. According to the C++ standard, what is sizeof(void)?
89. Output of the following program? #include #include int main () { std::vector int_values {3}; for (auto const& vv: int_values) { std::cout << vv; } }
90. int a[] {1, 2, 3}; a[[] { return 2; }()] += 2; What is the value of a[2]?
91. Is it possible to create class instance placed at a particular location in memory?
92. class foo { foo(){}; }; class boo : public foo { boo() : foo() {}; }; which standard allows compilation of this code.
93. What is value of x, if sizeof(int) == 4? unsigned int a = 0x98765432; unsigned int x = a >> 33;
94. Output of the program? int a, b = 3; const int& ar[]= {a, b}; ar[0] = 2; std::cout << ar[0];
95. std::vector<int> v(10); std::iota(v.begin(), v.end(), 10); What is the content of vector v?
96. Which function always returns an rvalue reference from 'x', which can be used to indicate the object is going to be destroyed soon?
97. bool is_even(int i) { return i % 2 == 0; } int v[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::partition(v, v + 10, is_even); What is the content of array v?
98. class A { int x; protected: int y; public: int z; }; class B: public virtual A { }; What is the privacy level of B::x?
99. The value of '(sizeof(short) == sizeof(int) && sizeof(int) == sizeof(long))' is
100. Output of the following program? template void foo(U&, T&) { std::cout << 'first'; } template void foo(int&, const T&) { std::cout << 'second'; } int main() { int a; double g = 2.; foo(a, g); return 0; }
101. Output of the following C++ code ? #include class A { int a; public: void foo() {std::cout<<'foo';} }; int main() { A* trial=nullptr; trial->foo(); }
102. Which of the following operators can you not overload?
103. const std::string * s; std::string const * g; What can be said about s and g?
104. Given this code, what is the output? #include struct shape { void move() { std::cout << 'shape::move\n'; } }; struct circle : public shape { void move() { std::cout << 'circle::move\n'; } }; struct rectangle : public shape { void move() { std::cout << 'rectangle::move\n'; } }; int main() { shape *s; s = new shape(); s->move(); s = new circle(); s->move(); s = new rectangle(); s->move(); return 0; }
105. std::function<int()> f; f(); f is not initialized. What exception is thrown, when you try to call it?
106. How do you declare a pointer where the memory location being pointed to cannot be altered, but the value being pointed to can?
107. Which is not a member of std::weak_ptr?
108. What will be the output? auto fn = [](unsigned char a){ cout << std::hex << (int)a << endl; }; fn(-1);
109. What is the purpose of std::set_union?
110. Suppose that a global variable 'x' of type std::atomic with an initializer parameter of 20 should be added to a header and (if necessary) source file so it is available to all files that include it. How should this be implemented where it will cause neither compile nor linker errors when compiling multiple object files together? Assume that a header guard and #include is already present in the header (though not shown in the answers), and that C++11 is enabled.
111. What is the value of 'v'? auto &p = 10; double v = p;
112. Virtual inheritance is needed...
113. Output of the following program: struct A { A() { std::cout << 'A'; } template A(Args&&... args) { std::cout << 'B'; } A(const A&) { std::cout << 'C; } }; int main() { A a; A b = a; }
114. std::deque<int> queue; queue.push_back(1); int& ref = queue.back(); queue.push_back(2); Where does ref point to?
115. What would the following program print? class Printer{ public: Printer(std::string name) {std::cout << name;} }; class Container{ public: Container() : b('b'), a('a') {} Printer a; Printer b; }; int main(){ Container c; return 0; }
116. Assuming a 32-bit compiler on an x86 platform, what would the result of sizeof(A) typically be? struct A { char B; int* C; short D; };
117. Below code fails to compile. class A { public: int GetValue() const { vv = 1; return vv; } private: int vv; }; Which of the following choices results in fixing this compilation error?
118. According to the IEEE standard, which will always evaluate to true if the value of 'var' is NaN?
119. int* a = {1, 2, 3}; | Where are the 1,2,3 values stored?
120. signed int a = 5; unsigned char b = -5; unsigned int c = a > b; What is the value of c?
121. If sizeof(int)==4 what is sizeof(long)?
122. If after: a* var = new a(); var's value is 0x000C45710 What is its value after: delete var;
123. With: struct foo { int a:3, b:4, :0; int c:4, d:5; int e:3; }; Determine if each statement is true or false: Concurrent modification of foo::a and foo::c is or might be a data race. Concurrent modification of foo::a and foo::b is or might be a data race. Concurrent modification of foo::c and foo::e is or might be a data race.
124. class A { int x; protected: int y; public: int z; }; class B: private A { public: using A::y; }; What is the privacy level of B::y?
125. If we have a class myClass , what can we say about the code: myClass::~myClass(){ delete this; this = NULL; }
126. Is the following well-formatted C++11 code? %:include int main (void) <% std::vector ivec <% 1, 2, 3 }; ??>
127. What can we say about: myClass::foo(){ delete this; } .. void func(){ myClass *a = new myClass(); a->foo(); }
128. In this class definition: class my_lock { std::atomic data; public: my_lock() : data{1} {} void unlock() { data = 1; } void lock(); } which could be used to complete the lock function, assuming the purpose of the above code is to create a mutex-like locking mechanism? Assume C++11.
129. According to the C++11 standard, which of these is a keyword?
130. Value of bar(1) in: int foo(int &x) { return ++x; } int bar(int x) { x += foo(x); return x; }
131. double a = 1.0; double *p = &a; a = a/*p; Which of the following statements about the code is true?
132. What will a declaration such as 'extern 'C' char foo(int);' do?
133. What does operator -> () do?
134. What type of exceptions will this function throw: int myfunction (int a) throw();?
135. Can a static member function be declared as const?
136. What is the effect of 'const' following a member function's parameter declarations?
137. In C++ the three STL (Standard Template Library) container adapters are:
138. What is the value of (false - ~0)?
139. Identifying classes by their standard typedefs, which of the following is NOT declared by the standard C++ library?
140. A memory leak occurs when:
141. A class declaration requires a semi-colon (;) after it is complete. Ie. Class MyClass { some code here };
142. No difference between a * pointer and an & reference.
143. The modulus (%) operator can be a slow operation on some processors, as it can require the processor to make three separate operations, depending on the CPU architecture.
144. All of the following are true EXCEPT:
145. An asterisk (*) immediately after a data type declares a variable as a pointer, and...
146. A template class does all of the following EXCEPT
147. In C++, Output of the code? #include main() { for (int x=1; x<10; ++x) { ++x; } cout << x; return 0; }
148. How can we make a class abstract?
149. Which statement about virtual base classes is correct?
150. C++ is strongly Object Oriented Language ?
151. Which will use the given code to do? std::vector foo {5}; (assume C++11)
152. Which process does operator+ perform on two instances of std::string?
153. char * array = 'Hello'; char array[] = 'Hello'; What is the difference between the above two, if any, when using sizeof operator?
154. Term describes an ordered and indexed sequence of values?
155. Which is the dynamic memory requested by C++ programs allocated?
156. Which of the following is the value of a = 11 % 3;?
157. Correct term for two different C++ functions that have the same name but different parameter types?
158. Which symbols calls the pre-processor to include the specified system files such as iostream?
159. Which of the following means the same as the statement below? i += 5;
160. From which programming language was C++ derived?
161. Which term can describe int, long, double, and string?
162. Symbol separates C++ statements?
163. C++ program execution starts from?
164. Which C++ function declarations is valid and passes the the function parameters by reference?
165. True or False: Classes can contain static member variables that are global to the class and can be accessed by all objects of the same class.
166. Which function prototypes will overload the addition operator between two objects of the type Distance?
167. Correct value of 7 == 5+2 ? 4 : 3?
168. Difference between an array and a vector?
169. How should the main part of program access myNamespace variable a, given the code below? namespace myNamespace { int a; int b; }
170. Which is the default access level assigned to members of a class?
171. The process of TYPECASTING makes one variable appear to be another type of data. Which of the following are the two processes of TYPECASTING?
172. Which statement declares a function with a default value for an argument?
173. The printmsg function does not require any arguments. Which of the following statements calls the printmsg function?
174. Which statement declares a function with arguments passed by reference?
175. Output of the following program? int main () { cout << 'Hello World!'; return 0; }
176. Value of C in code? int C++;
177. Which is the proper way to use the .substr() function on the following string to get the word 'World' in the following code? string aString = 'Hello World!';
178. If class B inherits class A, A::x() and is declared virtual, and B::x() overrides A::x(), which method x() will be called by the following code? B b; b.x();
179. Which of the following does 'int *p; p = 0;' do?
180. Difference between classes and structures?
181. What does below code create? int * p; p=0;?
182. Given an external function that needs access to private and protected members of a class, you would specify the function as:
183. Which is not permitted in a pure virtual class in C++?
184. Given the following code: void foo(){ static int x=10; } When is x created?
185. Which of the following do the ellipses indicate, given the code sample below? catch(…) { cout << 'exception';}.
186. Purpose of the following line serve in a C++ program? #include
187. For which circumstance should you use the preprocessor directive #include <iostream> in your C++ program?
188. A structure item exists in your code with integer member units. Given the following variable declaration, how should you access the value of units? item * myItem;.
189. Right way to place an opening curly bracket in C++?
190. Difference between the following? int a(0); and int a = 0;
191. Which is the content of vector v in code? std::vector v(4); std::fill(v.begin(), v.end(), 4);
192. Output of the code? std::cout << x;
193. Which is a variable that holds a large group of similar type data?
194. Initial value of result if the following variable definition is declared inside a function body? int result;
195. Is this program correct? class A { int a; friend class B; }; class B { friend class C; }; class C { void foo() { A a; a.a = 4; } };
196. How many bytes of memory does an instance of foo occupy? class foo { int x; short y; };
197. Which is the difference between these two declarations in C++? void foo(); void foo(void);
198. Which members and functions can only be accessed from within the class in which it was defined and from within its derived classes?
199. Which of the following statements are true?
200. How many arguments can be passed to an overloaded binary operator?
201. Which is a function that returns a non zero value to indicate an I/O stream error?
202. Consider the following code: class BaseException { public: virtual void Output() { cout << 'Base Exception' << endl; } }; class DerivedException : public BaseException { public: virtual void Output() { cout << 'Derived Exception' << endl; } }; void ExceptionTest() { try { throw new DerivedException(); } catch (DerivedException ex) { ex.Output(); } catch (...) { cout << 'Unknown Exception Thrown!' << endl; } } Invoking Exception Test will result in which output?
203. Consider the following code: class A { typedef int I; // private member I f(); friend I g(I); static I x; }; Which of the following are valid:
204. Suppose MyClass is a class that defines a copy constructor and overloads the assignment operator. In which of the following cases will the copy constructor of MyClass be called?
205. Which STL classes is deprecated (ie should no longer be used)
206. Unary operator overloaded by means of a friend function takes one reference argument.
207. Output of the following code? #include using namespace std; class b { int i; public: void vfoo() { cout <<'In Base '; } }; class d : public b { int j; public: void vfoo() { cout<<'In Derived '; } }; void main() { b *p, ob; d ob2; p = &ob; p->vfoo(); p = &ob2; p->vfoo(); ob2.vfoo(); }
208. Which operators cannot be overloaded?
209. Consider the following code: #include using namespace std; int main() { cout << 'The value of __LINE__ is ' <<__LINE__; return 0; } What will be the result when the above code is compiled and executed?
210. If a matching catch handler (or ellipsis catch handler) cannot be found for the current exception, then the following predefined runtime function is called ______.
211. Which sets of functions do not qualify as overloaded functions?
212. Which is true about class member function and constructor?
213. Which is a predefined object in C++ and used to insert to the standard error output?
214. Consider the following code: class Animal { private: int weight; public: Animal() { } virtual void Speak() { cout << 'Animal speaking'; } }; class Snake : public Animal { private: int length; public: Snake() { } void Speak() { cout << 'Snake speaking\r\n'; } }; int main() { Animal *array = new Snake[10]; for (int index= 0; index < 10; index++) { array->Speak(); array++; } return 0; } What happens when the above code is compiled and executed?
215. A pure virtual function can be declared by _______.
216. Which statement regarding functions is false?
217. Answer the question that follows. 1 class Car 2 { 3 private: 4 int Wheels; 5 6 public: 7 Car(int wheels = 0) 8 : Wheels(wheels) 9 { 10 } 11 12 int GetWheels() 13 { 14 return Wheels; 15 } 16 }; 17 main() 18 { 19 Car c(4); 20 cout << 'No of wheels:' << c.GetWheels(); 21 } Which of the following lines from the sample code above are examples of data member definition?
218. What linkage specifier do you use in order to cause your C++ functions to have C linkage
219. Consider the following code: #include int main(int argc, char* argv[]) { enum Colors { red, blue, white = 5, yellow, green, pink }; Colors color = green; printf('%d', color); return 0; } What will be the output when the above code is compiled and executed?
220. Which statement is true for operator overloading in C++?
221. Answer the question that follows. class Person { string name; int age; Person *spouse; public: Person(string sName); Person(string sName, int nAge); Person(const Person& p); Copy(Person *p); Copy(const Person &p); SetSpouse(Person *s); }; Which one of the following are declarations for a copy constructor?
222. Which statement about function overloading, is true?
223. In C++, the keyword auto can be used for:
224. In C++, the keyword auto can be used for:
225. What does ADT stand for?
226. Which is NOT a standard sorting algorithm:
227. Consider the following code: #define SQ(a) (a*a) int answer = SQ(2 + 3); What will be the value of answer after the above code executes?
228. Consider two classes A and B: class A { private: int x; float y; public: friend class B; }; class B { }; Which of the following is true?
229. Answer the question that follows. class screen; Which of the following statements are true about the class declaration above?
230. Output of the following code? class b { int i; public: virtual void vfoo() { cout <<'Base '; } }; class d1 : public b { int j; public: void vfoo() { j++; cout <<'Derived'; } }; class d2 : public d1 { int k; }; void main() { b *p, ob; d2 ob2; p = &ob; p->vfoo(); p = &ob2; p->vfoo(); }
231. Choose the option related to static member functions: 1. They have external linkage 2. They do not have 'this' pointers 3. They can be declared as virtual 4. They can have the same name as a non-static function that has the same argument types
232. Answer the question that follows. class SomeClass { int x; public: SomeClass (int xx) : x(xx) {} }; SomeClass x(10); SomeClass y(x); What is wrong with the sample code above?
233. Which is NOT valid C++ casts
234. Answer the question that follows. template Run(T process); Which one of the following is an example of the sample code given above?
235. Which of the following is not a standard STL header?
236. You want the data member of a class to be accessed only by itself and by the class derived from it. Which access specifier will you give to the data member?
237. Which statement about constructor and destructor is true?
238. Answer the question that follows. class Grandpa { } ; class Ma : virtual public Grandpa { } ; class Pa : virtual public Grandpa { } ; class Me : public Ma, public Pa, virtual public Grandpa { } ; How many instances of Grandpa will each instance of Me contain?
239. Which techniques should you use to handle a destructor that fails?
240. Which is true about class and struct in C++:
241. Output of the following code? int n = 9; int *p; p=&n; n++; cout << *p+2 << ',' << n;
242. Answer the question that follows. class A { public: A() {} ~A() { cout << 'in destructor' << endl; } }; void main() { A a; a.~A(); } How many times will 'in destructor' be output when the above code is compiled and executed?
243. Consider the following class hierarchy: class Base { } class Derived : public Base { } Which of the following are true?
244. Sample Code typedef char *monthTable[3]; Referring to the code above, which of the following choices creates two monthTable arrays and initializes one of the two?
245. Which statement is FALSE with regard to destructors
246. Answer the question that follows. class X { int i; protected: float f; public: char c; }; class Y : private X { }; Referring to the sample code above, which of the following data members of X are accessible from class Y
247. Which constructor definition valid? class someclass { int var1, var2; public: someclass(int num1, int num2) : var1(num1), var2(num2) { } };
248. No, var1 and var2 are not functions but are variables
249. which of the following is true.
250. Which of the following STL classes is deprecated (i.e should no longer be used)?
251. Answer the question that follows: char **foo; /* Missing code goes here */ for(int i = 0; i < 200; i++) { foo[i] = new char[100]; } Referring to the sample code above, what is the missing line of code?
252. If input and output operations have to be performed on a file, an object of the _______ class should be created.
253. Output of the following code? class A { public: A():pData(0){} ~A(){} int operator ++() { pData++; cout << 'In first '; return pData; } int operator ++(int) { pData++; cout << 'In second '; return pData; } private: int pData; }; void main() { A a; cout << a++; cout << ++a; }
254. Which member functions can be used to add an element in an std::vector?
255. Output of the following code? #include using namespace std; class myclass { private: int number; public: myclass() { number = 2; } int &a() { return number; } }; int main() { myclass m1,m2; m1.a() = 5; m2.a() = m1.a(); cout << m2.a(); return 0; }
256. Consider the following code: #include using namespace std; class A { public: A() { cout << 'Constructor of A\n'; }; ~A() { cout << 'Destructor of A\n'; }; }; class B { public: B() { cout << 'Constructor of B\n'; }; ~B() { cout << 'Destructor of B\n'; }; }; class C { public: A objA; B objB; }; int main() { C *pC; pC = new C(); delete pC; return 0; } What will be the printed output?
257. Answer the question that follows. class Person { public: Person(); virtual ~Person(); }; class Student : public Person { public: Student(); ~Student(); }; main() { Person *p = new Student(); delete p; } Why is the keyword 'virtual' added before the Person destructor?
258. Answer the question that follows. class Outer { public: class Inner { int Count; public: Inner(){}; }; }; int main() { Inner innerObject; Outer outObject; return 0; } What will be the result when the above code is compiled?
259. Output of the code? class Shape { public: virtual void draw() = 0; }; class Rectangle: public Shape { public: void draw() { // Code to draw rectangle } //Some more member functions..... }; class Circle : public Shape { public: void draw() { // Code to draw circle } //Some more member functions..... }; int main() { Shape objShape; objShape.draw(); } What happens if the above program is compiled and executed?
260. Which types of inheritance supported in C++?
261. Which is TRUE? (Choose all that apply)
262. Which statement is true? (Choose all that apply.)
263. Which of the following statement is correct? (Choose all that apply)
264. Which is not a member of a class?
265. What happens when a handler is not found for a given exception?
266. How many number of arguments can a destructor of a class receives?
267. Runtime polymorphism is achieved only when a virtual function is accessed through a ____ to the base class.
268. Which operator is used to allocate memory?
269. Which storage classes are supported in C++?
270. The stream ‘cout’ is by default connected to console output ___.
271. Which members are not accessed by using the direct member access operator?
272. Copy constructor must receive its arguments by ___?
273. The pointer which stores the current active object address is ___
274. To which type of class we can apply RTTI?
275. Which is used to create a pure Virtual function?
276. How many default constructors per class are possible?
277. Void pointer can point to which type of objects?
278. Which is not a type of constructor?
279. Which is true in relation to destructors for automatic objects if a program terminates with a call to a function exit?
280. What does container adapter provide to interface?
281. Which of the following statements are correct? (Choose all that apply)
282. Which constructor function is designed to copy objects of the same class type?
283. A constructor that accepts ____ parameters is called default constructor.
284. If a copy constructor receives its arguments by-value, the copy constructor will ____.
285. Destructor has the same name as constructor and it is preceded by ___?
286. Which is true about destructors?
287. Which statements is/are correct?
288. How many objects can be created from an abstract class?
289. Which keywords is used to control access to a class member?
290. Which type of data member can be shared by all instances of a class?
291. What is a function template?
292. Every object in the array receives a destructor call, always delete memory allocated as an array with operator ___.
293. Which statement is incorrect?
294. Which access specifier is used in a class definition by default?
295. Which gets called when an object goes out of scope?
296. Output of following code:- #include using namespace std; int main() { int a = 1, b = 2, c, d; c = a, b; d = (a, b); cout << c << ' ' << d; return 0; }
297. Output of the following? #include using namespace std; int main () { int x, y; x = 1; y = ++x * ++x; cout << x << y; x = 1; y = x++ * ++x; cout << x << y; return 0; }
298. Output of following program? #include using namespace std; int main() { int i, j; j = 0; i = (j++, j + 1, 2 + j); cout << i; return 0; }
299. Which is true? (Choose all that apply)
300. Which is TRUE? (Choose all that apply)
301. What are the names of default standard streams in C++?
302. How many adapters support the checked iterators?
303. Which statement is correct about the references?
304. Which operator is used to resolve the scope of the global variable?
305. Output of following code? include using namespace std; namespace fun1 { int a = 6; } namespace fun2 { int a = 11; } int main(int argc, const char * argv[]) { int a = 10; fun1::a; fun2::a; cout << a; return 0; }
306. A reference is stored on ___.
307. Functions can be declared to return a reference type. Which is correct reasons to make such a declaration? (Choose all that apply)
308. Which is a valid statement regarding cin.read()?
309. A reference is declared using ___ symbol?
310. Which symbol is used to declare the preprocessor directives?
311. Which is best source codes? A) intscan_buffer(char *buffer, intbuffer_size) { // serach malware patterns for(inti = 0; i< PATN_CNT; i++) { intlen = strlen(malware_pattern[i]); for (int j = 0; j
312. Function overloading is an example of ___?
313. What does the function objects implement?
314. C++ ____ for local variables are called at the end of the object lifetime?
315. What is a template?
316. Output of following program? #include using namespace std; int main() { char* upwork; try { upwork = new char[1024]; if (upwork == 0) throw 'Projects'; else cout<
317. How many members does the below Freelancer class has? class Upwork { public: int freelancers; int jobs; int projects; private: double income; double costs; }; struct World { int inhabitants; double gdp; int countries; }; class Project { public: char* client; char* title; double hours; double rate; private: char* dialog; char* ip; }; class Freelancer : Upwork, World, Project { private: char* name; };
318. What is the output of following code? #include using namespace std; void Upwork(); int main() { try { Upwork(); } catch(double) { cerr<< 'Projects' <
319. When your program allocates memory on the free store, a _____ is returned?
320. union U { int x; double d; }; int main() { U a; a.x = 7; a.d = 7.7; int y = a.x; // <------ breakpoint placed here } What is the value held by a.x when the above breakpoint is reached?
321. Which you can use to pass an array object to a function?
322. Which operator is used to deallocate the memory?
323. This code? while (numforks= maxf) { wait(NULL); numforks--; } }
324. This C++ definition: int* x = 0; Which of the following expressions refers to the location of the variable x in memory?
325. Below sequence of C++ statements? int a = 7; int& r = a; r = 8;
326. Reference is like a ____.
327. Best way to implement mathematical matrix operation such as plus, minus and multiply with C++? A- Define matrix operation functions like below. Matrix Matrix :: pls(Matrix mat1, Matrix mat2); Matrix Matrix :: min(Matrix mat1, Matrix mat2); Matrix Matrix :: mlt(Matrix mat1, Matrix mat2); B- Override operators like below Matrix Matrix :: operator +(Matrix m2) Matrix Matrix :: operator -(Matrix m2) Matrix Matrix :: operator *(Matrix m2)
328. Correct way to declare a function as constant?
329. Cannot read /proc//mem file even with root privilege due to permission error. How to solve it? intmem_file = open(“/proc/12345/mem”, O_RDONLY); // returns permission error
330. This code: template void Kill(T *&objPtr) { delete objPtr; objPtr = NULL; } class MyClass { }; void Test() { MyClass *ptr = new MyClass(); Kill(ptr); Kill(ptr); } Invoking Test() will cause which of the following?
331. Code will exhibit undefined behavio What will be the result of calling the h() function in the following C++ code? const char* upwork[] = { "Freelancers", "Projects", "Fixed", "Hourly" } const char* f(inti) { return upwork[i]; } void g(string s){} void h() { const string& r = f(0); g(f(1)); string s = f(2); cout<< "f(3): " << f(3) << " s: " << s << " r: " << r << '\n'; }
332. Which of the following statements are true about conversions in C++? (Choose all that apply.)
333. Which is valid declaration or definition of a pointer?
334. 27- Does an exception have to be caught in the same place where the try block created the exception?
335. Which statements are correct? Check all that apply.
336. Maximum number of elements that can be added to a linked list?
337. Which will compile, link and run OK in C++? (Choose all that apply.)
338. Point out proper answer about the difference between below source codes for the execution of external commands if (fork() == 0) { execve(path, args, env); exit(1); } and FILE *fp = popen(path, “r”); if (fp) { pclose(fp); }
339. How many types of templates are there in C++?
340. Which of the following statement is correct?
341. Which of the following statement is correct?
342. Study and select proper answer? ifdef defined(__x86_64__) static inline unsigned long long rdtsc(void) { unsigned hi, lo; asm volatile ('rdtsc' : '=a'(lo), '=d'(hi)); return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 ); } elif defined(powerpc) static inline unsigned long long rdtsc(void) { unsigned long long int result=0; unsigned long int upper, lower,tmp; asm volatile( '0: \n' '\tmftbu %0 \n' '\tmftb %1 \n' '\tmftbu %2 \n' '\tcmpw %2,%0 \n' '\tbne 0b \n' : '=r'(upper),'=r'(lower),'=r'(tmp) ); result = upper; result = result<<32; result = result|lower; return(result); } endif
343. How to make the C/C++ source can be built for any architecture,select proper answer?
344. Which of the following statement is correct?
345. Which function prototype is VALID? (Choose all that apply)
346. When arguments are passed to a destructor it is call a '___' error.
347. How can you declare a template?
348. How many members does the below Freelancer class have? class Upwork { public: int freelancers; int jobs; int projects; private: double income; double costs; }; struct World { int inhabitants; double gdp; int countries; }; class Project { public: char* client; char* title; double hours; double rate; private: char* dialog; char* ip; }; class Freelancer : Upwork, World, Project { private: char* name; };
349. C++ provides the ability to define _________ and ___________ as its primary encapsulation mechanisms.
350. An operator '____' will allow you to delete memory allocated as an array which will ensure that every object in the array will receive a destructor call.
351. What is the output of the following code? #include using namespace std; struct val { int a; char b; }; int main(int argc, const char * argv[]) { struct val s ={19,49}; struct val *ps =(struct val *)&s; cout << ps->a << ps->b; return 0; }
352. What is the output of the following code? #include using namespace std; void func(int x) { cout << x ; } int main(int argc, const char * argv[]) { void (*n)(int); n = &func; (*n)( 5 ); n( 8 ); return 0; }
353. Which is NOT provided by the compiler by default?
354. Which of the following is used to create an object by initializing it with an object of the same class that has been created previously?
355. Destructor calls are made in which order of the corresponding constructor calls?
356. Which function cannot be overloaded?
357. Which of the following will compile, link and run OK in C++? (Choose all that apply.)
358. ____ is a parameterized stream manipulator.
359. ____ is a valid char value.
360. ________ member function may be called by a statement in a function that is outside the class.
361. A binary search begins with the ________ element of an array.
362. A class may have ________ default constructor(s) and ________ destructor(s).
363. A function can have zero to many parameters, and it can have ________ return value(s).
364. A(n) ________ can be used to specify the starting values of an array.
365. An array with no elements is ________.
366. An element of a two-dimensional array is referred to by ________ followed by ________.
367. Every complete c++ program must have a __________.
368. Subscript numbering in c++________.
369. ____ consists of 65,536 characters.
370. ________ are c++ operators that change their operands by one.
371. ________ must be included in any program that uses the cout object.
372. A catch block can have, at most, ____ catch block parameter(s).
373. A class ____ automatically executes whenever a class object goes out of scope.
374. A destructor has the character ____, followed by the name of the class.
375. A function ________ contains the statements that make up the function.
376. A function ________ is a statement that causes a function to execute.
377. A function ________ return a structure.
378. A function ____________________ is a function that is not fully coded.
379. A program called a(n) ____ combines the object program with the programs from libraries.
380. A program that tests a function is called a _____ program.
381. A stack can be implemented as either a(n) ____ or a linked structure.
382. A struct variable can be passed as a parameter ____.
383. A structure ________ contain members of the same data type.
384. An operation that copies a value into a variable is called a(n) ________ operation.
385. Arguments are passed to the base class destructor function by the ________ class ________ function.
386. Array elements must be ________ before a binary search can be performed.
387. Array subscripts are always a sequence of ____.
388. Arrays must be ________ at the time they are ________.
389. Before a structure variable can be created, the structure must be _________.
390. C++ allows you to redefine the way ________ work when used with class objects.
391. C++ automatically places ________ at the end of a string constant (string literal).
392. Class templates are called ____ types.
393. Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).
394. If a member of a class is ____, you cannot access it outside the class.
395. If a while loop has no braces around the body of the loop ________.
396. In ____ binding, the necessary code to call a specific function is generated by the compiler.
397. In a sequence of try/catch blocks, the last catch block of that sequence should be ____.
398. In a(n) ____ copy, two or more pointers have their own data.
399. In any program that uses the cin object, you must include the ________.
400. In c++, ____ is a reserved word.
401. In c++, ____ is called the address of operator.
402. In c++, the ____ symbol is an operator, called the member access operator.
403. In c++, the null character is represented as ____.
404. In c++, the scope resolution operator is ____.
405. In c++, virtual functions are declared using the reserved word ____.
406. In memory, c++ automatically places a ________ at the end of string literals.
407. Inheritance is an example of a(n) ____ relationship.
408. Main memory is an ordered sequence of items, called ____.
409. Main memory is called ____.
410. Multiple inheritance is when a ________ class has ________ base classes.
411. Polymorphism means ________.
412. When you derive a class from an existing class, you ________ add new data and functions.
413. The ____ members of an object form its internal state.
414. The ________ and ________ operators can be used to increment or decrement a pointer variable.
415. The ________ class constructor is called before the ________ class constructor.
416. The ________ is/are used to display information on the computer's screen.
417. The ________ library function reverses the order of a character array.
418. The ________ object enables a program to read data from the user.
419. The ________ of recursion is the number of times a recursive function calls itself.
420. "the ________ operator is used in c++ to test for equality.
421. The ________, also known as the address operator, returns the memory address of a variable.
422. The -- operator ________.
423. The >= is one of the __________ operators.
424. The addition and deletion of elements of a stack occurs only at the ____ of the stack.
425. The c-string company[12] can hold ________.
426. The c++ ________ operator represents logical and.
427. The c++ function ____ calculates the largest whole number that is less than or equal to x.
428. The c++ operator ____ is used to create dynamic variables.
429. The code int *p; declares p to be a(n) ____ variable.
430. The compiler checks ________.
431. The compiler performs ________ on virtual functions.
432. The components of a struct are called the ____ of the struct.
433. The conditional and operator in java, c++, and c# is ____.
434. The destructor function's return type is ________.
435. The do-while loop is a(n) ________ loop, whereas the while loop is a(n) ________ loop.
436. The expression x < y is called a(n) ________ expression.
437. The heading of the function is also called the ____.
438. The ideal type of loop to use if you want a user to enter exactly 20 values is a(n) ________ loop.
439. The statement: return 8, 10; returns the value ____.
440. The statements that may generate an exception are placed in a ____ block.
441. The std::endl stream manipulator________.
442. To access an array element, use the array name and the element's ________.
443. To pass an array as an argument to a function, pass the _________ of the array.
444. The programming language c++ evolved from ____.
445. Use the delete operator only on pointers that were ________.
446. The value in a(n) ________ variable persists between function calls.
447. A(n) ____ consists of data and the operations on those data.
448. The expression static_cast(6.9) + static_cast(7.9) evaluates to ____.
449. ____ loops are called posttest loops.
450. A class is a(n) ________ that is defined by the programmer.
451. A loop that continues to execute endlessly is called a(n) ____ loop.
452. A two-dimensional array is like ______________ put together.
453. A(n) ____ is a programmer-defined type, such as a class.
454. An array created during the execution of a program is called a(n) ____ array.
455. If you leave out the size declarator in an array declaration ________.
456. In a ____ copy, two or more pointers have their own data.
457. In an adt the implementation details are ________ the interface through which a program uses it.
458. Manipulators without parameters are part of the ____ header file.
459. The ________ constructor is called before the ________ constructor.
460. The primary outcome of the systems analysis phase is ____.
461. The value of the expression 33/10, assuming both values are integral data types, is ____.
462. When one control statement is located within another, it is said to be ____.
463. When you dereference an object pointer, use the ________.
464. When you work with a dereferenced pointer, you are actually working with ________.
465. With pointer variables, you can __________ manipulate data stored in other variables.
466. The following statement ________. int *ptr = new int;
467. The conditional operator ?: takes ____ arguments.
468. To use files in a c++ program you must include the ________ header file.
469. A file must be ________ before data can be written to or read from it.
470. A(n) ________ informs the compiler that a class will be declared later in the program.
471. A(n) ________ operator can work with programmer-defined data types.
472. Arrays may be ________ at the time they are ________.
473. In the swap module, the third variable is declared as a ________ variable.
474. The _____ of an identifier refers to where in the program an identifier is accessible.
475. The first step in using the string class is to #include the ________ header file.
476. The name of the function to overload the operator <= is ____.
477. The scope of a namespace member is local to the ____.
478. To test whether a character is a numeric digit character, use the ________ function.
479. In c++, the dot is an operator called the ____ operator.
480. ____ are executable statements that inform the user what to do.
481. C++ requires that a copy constructor's parameter be a(n) ________.
482. ____ are arrays that have more than one dimension.
483. ________ functions may have the same name, as long as their parameter lists are different.
484. A ________ value in a loop can be either a positive or a negative number.
485. A ___________ is a member function that is automatically called when a class object is ___________.
486. A(n) ____ is a numeric variable used for adding together something.
487. String constants and _____ refer to the same concept.
488. The memory allocated for a float value is ____ bytes.
489. To compare struct variables, you compare them ____.
490. To use the assert function in your program, you should include the statement ____.
491. When a copy of a variable is sent to a method, it is passed by ____.
492. You can assign the value of one struct variable to another struct variable of ____ type.
493. You may define a __________ in the initialization expression of a for loop.
494. Popping an element from an empty stack is called ____.
495. Dividing a problem into smaller subproblems is called ____ design
496. ________ functions are dynamically bound by the compiler.
497. A ________ file is like a stream of data that must be read from its beginning to its end.
498. A sorting algorithm can be used to arrange a set of ________ in ________ order.
499. A(n) ________ search uses a loop to sequentially step through an array.
500. Regardless of the algorithm being used, a search through an array is always performed ________.
501. The ________ of a variable is limited to the block in which it is declared.
502. The ________ sort usually performs more exchanges than the ________ sort.
503. The constructor function's return type is ________.
504. Writing a program in a language such as c++ or java is known as _______ the program.
505. You may define a(n) ________ in the initialization expression of a for loop.
506. You must have a(n) ________ for every variable you include in a program.
507. If a recursive function does not contain a base case, it ________.
508. Pseudocode uses the end-structure statement ____ to clearly show where the structure ends.
509. You can use either a(n) ___ variable or a bool variable to store the value of a logical expression.
510. The percent sign is the ____ operator.
511. The \ operator is the arithmetic operator for ____ division.
512. You may use a pointer to a structure as a ________.
513. A(n) ________ search is more efficient than a(n) ________ search
514. An array name and index are separated using ____.
515. To correctly swap two values, you create a(n) ____ variable to hold one of the values.
516. A function prototype is ____.
517. If you try to add a new item to a full stack, the resulting condition is called a(n) ____.
518. To use the strlen function in a program, you must also write #include ________.
519. The header file is also known as the ____________________.
520. C++ provides a header file called ____________________, which is used for file i/o.
521. Before using the data type string, the program must include the header file ____.
522. The standard header file for the abs(x)function is ____.
523. The function eof is a member of the data type ____________________.
524. The maximum number of entry points that any programming structure can have is ____.
525. To arrange the elements in an array in ascending order, you use the ____ method.
526. Data that is sorted in ascending order is ordered ________.
527. The ________ function concatenates the contents of one c-string with another c-string.
528. A subscript is a(n) _____.
529. The __________ function returns the smallest integer that is greater than or equal to the number.
530. The value of the expression 17 % 7 is ____.
531. A ____ defines the name and data type of program variables.
532. A ____ exception occurs when code attempts to divide a number by zero.
533. A ________ search uses a loop to sequentially step through an array.
534. Classes can create new classes from existing classes. this important feature ____.
535. In some programming languages, ___________ are implemented as arrays whose elements are characters.
536. Object-oriented programmers sometimes say an object is one ____ of a class.
537. Objects both in the real world and in object-oriented programming contain ____ and methods.
538. The ____ loop provides three actions in one compact statement.
539. The ____ operator can be used to return the address of a private data member of a class.
540. The class ____ is the base of the classes designed to handle exceptions.
541. The class dclass is derived from the class bclass using the ____ type of inheritance.
542. When ____ are introduced in a program, they are immediately given a value.
543. When the ________ is placed in front of a variable name, it returns the address of that variable.
544. ________ are data items whose values cannot change while the program is running.
545. ________ members of a base class are never accessible to a derived class.
546. In c++, ____ is called the scope resolution operator.
547. An example of a floating point data type is ____.
548. Data sent by a program to the screen, a printer, or a file is __________.
549. Data types that are created by the programmer are known as ________.
550. When you write a program that stores a value in a variable, you are using ____ storage.
551. You can use the ____ operator to increment or decrement the value of an enumeration type.
552. _____ are programs that test code to ensure that it contains no syntax errors.
553. Another term for repetition structures is __________
554. Dynamic memory allocation occurs ________.
555. Each node of a singly linked list has two components: ____ and ____.
556. In c++, :: is called the scope ____ operator.
557. A ______ is a symbol used to represent a location in memory.
558. A for loop is considered a(n) ________ loop.
559. A variable listed in a header is known as a(n) ____ parameter.
560. Which of the following is a reason why using this line is considered a bad practice? (Alternative: Why is using this line considered a bad practice?) Using namespace std;
561. Which of the following is a true statement about the difference between pointers and iterators?
562. What's a benefit of declaring the parameter as a const reference instead of declaring it as a regular object? int median(const my_array& a);
563. Which of the following operators is overloadable?
564. Which of the following is not a difference between a class and a struct?
565. What is an lvalue?
566. What does auto type specifier do in this line of code (since C++11)? auto x = 4000.22;
567. A class template is a _?
568. What is the ternary operator equivalent to this code snippet? if(x) y=a; else y=b;
569. What is the meaning of the two parts specified between parentheses in a range-based for loop, separated by a colon?
570. Which STL class is the best fit for implementing a collection of data that is always ordered so that the pop operation always gets the greatest of the elements? Suppose you are interested only in push and pop operations.
571. What is the meaning of the three sections specified between parentheses in a for loop separated by semicolons?
572. What is true about the variable named ptr? void *ptr;
573. What is the output of this code? int c=3; char d='A'; std::printf("c is %d and d is %c",c,d);
574. What is the output of this code? printf("1/2 = %f",(float)(1/2));
575. What is the difference between a public and a private class member?
576. What is the value of x after running this code? int x=10, a=-3; x=+a;
577. Which statement is true?
578. Consider a pointer to void, named ptr, which has been set to point to a floating point variable g. Which choice is a valid way to dereference ptr to assign its pointed value to a float variable f later in the program? float g; void *ptr=&g;
579. What is the .* operator and what does it do?
580. How can C++ code call a C function?
581. What does this part of a main.cpp file do? #include "library.h"
582. What's wrong with this definition when using a pre-C++11 compiler?
583. What is the statement below equivalent to? sprite->x
584. What would be the output of this code? int32_t nums[3]={2,4,3}; std::cout << ( nums[0] << nums[1] << nums[2] );
585. Which of the following STL classes is the best fit for implementing a phonebook? Suppose each entry contains a name and a phone number, with no duplicates, and you want to have lookup by name.
586. Which of the following is not a consequence of declaring the member variable count of my_class as static? class my_class { public: static int count;}
587. What is the assumed type of a constant represented in the source code as 0.44?
588. What is an appropriate way of removing my_object as shown below? my_class *my_object = new my_class();
589. What is this expression equivalent to? A->B->C->D
590. What does this function do? auto buff = new char[50]; Std::memset(buff,20,50);
591. Consider a class named CustomData. Which choice is a correct declaration syntax to overload the postfix ++ operator as a class member?
592. What is the purpose of a destructor?
593. Which STL class is the best fit for implementing a phonebook? Suppose each entry contains a name and a phone number, with no duplicates, and you want to have lookup by name.
594. What is the main difference between these two Functions? std::mutex::lock() Std::mutex::try_lock()
595. What is one benefit of declaring the parameter as a const reference instead of declaring it as a regular object? int median(const my_array& a)
596. What is an include guard?
597. What is the purpose of this line in a header file? #pragma once
598. What is a variable of type double?
599. Consider this function declaration of is_even, which takes in an integer and returns true if the argument is an even number and false otherwise. Which declarations are correct for overloaded versions of that function to support floating point numbers and string representations of numbers? bool is_even(int);
600. Other than shifting bits to the left, what is the << oprator used for ?
601. Which choice is a reason to specify the type of a pointer instead of using void *, which works as a pointer ro any type?
602. What is this expression equivalent to?
603. Which statement is true when declaring the member variable count as static? class my_class{ public: static int count;};
604. When placed in a valid execution context, which statement will dynamically allocate memory from the heap for an integer of value 11?
605. Which choice best describes the type long?
606. Which of the following types has the closest functionality to a class?
607. The do-while loop is considered a(n) _________ loop.
608. A(n) ________ is a variable, usually a bool, that signals when a condition exists.
609. _______ is a construct that defines objects of the same type.
610. ________ must be included in a program in order to use the cout object.
611. ________ to a base class may be assigned the address of a derived class object.
612. A ____ structure is also referred to as a loop.
613. A variable's ________ is the part of a program in which the variable may be accessed.
614. In c++, you can create aliases to a previously defined data type by using the ____ statement.
615. Every byte in the computer's memory is assigned a unique ________.
616. A(n) ____________________ is a memory location whose contents can be changed.
617. An array can easily be stepped through by using a ________.
618. An array's size declarator must be a(n)________ with a value greater than ________.
619. The ________ sort usually performs fewer exchanges than the ________ sort.
620. Consider the following statement: double alpha[10][5];. the number of components of alpha is ____.
621. Closing a file causes any unsaved information still held in the file buffer to be ________.
622. The ____________________ of relational and logical operators is said to be from left to right.