MCQs > IT & Programming > C++ MCQs > Basic C++ MCQs

Basic C++ MCQ

1. The ____________________ of relational and logical operators is said to be from left to right.

Answer

Correct Answer: Associativity

Note: This Question is unanswered, help us to find answer for this one

2. Closing a file causes any unsaved information still held in the file buffer to be ________.

Answer

Correct Answer: Saved to the file

Note: This Question is unanswered, help us to find answer for this one

3. Consider the following statement: double alpha[10][5];. the number of components of alpha is ____.

Answer

Correct Answer: 50

Note: This Question is unanswered, help us to find answer for this one

4. The ________ sort usually performs fewer exchanges than the ________ sort.

Answer

Correct Answer: Selection, bubble

Note: This Question is unanswered, help us to find answer for this one

5. An array's size declarator must be a(n)________ with a value greater than ________.

Answer

Correct Answer: Constant integer expression, zero

Note: This Question is unanswered, help us to find answer for this one

6. An array can easily be stepped through by using a ________.

Answer

Correct Answer: For loop.

Note: This Question is unanswered, help us to find answer for this one

7. A(n) ____________________ is a memory location whose contents can be changed.

Answer

Correct Answer: Variable

Note: This Question is unanswered, help us to find answer for this one

8. Every byte in the computer's memory is assigned a unique ________.

Answer

Correct Answer: Address

Note: This Question is unanswered, help us to find answer for this one

9. In c++, you can create aliases to a previously defined data type by using the ____ statement.

Answer

Correct Answer: Typedef

Note: This Question is unanswered, help us to find answer for this one

10. A variable's ________ is the part of a program in which the variable may be accessed.

Answer

Correct Answer: Scope

Note: This Question is unanswered, help us to find answer for this one

11. A ____ structure is also referred to as a loop.

Answer

Correct Answer: Repetition

Note: This Question is unanswered, help us to find answer for this one

12. ________ to a base class may be assigned the address of a derived class object.

Answer

Correct Answer: Private members

Note: This Question is unanswered, help us to find answer for this one

13. ________ must be included in a program in order to use the cout object.

Answer

Correct Answer: The header file iostream

Note: This Question is unanswered, help us to find answer for this one

14. _______ is a construct that defines objects of the same type.

Answer

Correct Answer: An object

Note: This Question is unanswered, help us to find answer for this one

15. A(n) ________ is a variable, usually a bool, that signals when a condition exists.

Answer

Correct Answer: Flag

Note: This Question is unanswered, help us to find answer for this one

16. The do-while loop is considered a(n) _________ loop.

Answer

Correct Answer: Post-test.

Note: This Question is unanswered, help us to find answer for this one

17. Which statement is true when declaring the member variable count as static? class my_class{ public: static int count;};

Answer

Correct Answer: The variable cannot be modified by any part of the code in the same application or thread. However, other threads may modify it.

Note: This Question is unanswered, help us to find answer for this one

18. What is this expression equivalent to?

Answer

Correct Answer: (*A).B

Note: This Question is unanswered, help us to find answer for this one

19. Which choice is a reason to specify the type of a pointer instead of using void *, which works as a pointer ro any type?

Answer

Correct Answer: The compiler needs the data type to know how much memory to allocate for the pointer, because different data types require different pointer lengths.

Note: This Question is unanswered, help us to find answer for this one

20. Other than shifting bits to the left, what is the << oprator used for ?

Answer

Correct Answer: Inserting characters into an output stream like std::cout.

Note: This Question is unanswered, help us to find answer for this one

21. 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);

Answer

Correct Answer: Bool is_even(float f); bool is_even(char *str);

Note: This Question is unanswered, help us to find answer for this one

22. What is a variable of type double?

Answer

Correct Answer: A floating point number

Note: This Question is unanswered, help us to find answer for this one

23. What is the purpose of this line in a header file? #pragma once

Answer

Correct Answer: To make the compiler parse that header file only once, even if it is included multiple times in the source

Note: This Question is unanswered, help us to find answer for this one

24. 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)

Answer

Correct Answer: The const qualifier Forbids the code to modify the argument, so the programmer can rest assured that the source object will remain unchanged.

Note: This Question is unanswered, help us to find answer for this one

25. What is the main difference between these two Functions? std::mutex::lock() Std::mutex::try_lock()

Answer

Correct Answer: Both attempt to acquire a lock, but lock() blocks if the mutex is not available, whereas try_lock() returns whether the mutex is available or not.

Note: This Question is unanswered, help us to find answer for this one

26. What is the purpose of a destructor?

Answer

Correct Answer: It allows the programmer to write the necessary code to free the resources acquired by the object prior to deleting the object itself.

Note: This Question is unanswered, help us to find answer for this one

27. Consider a class named CustomData. Which choice is a correct declaration syntax to overload the postfix ++ operator as a class member?

Answer

Correct Answer: CustomData operator++(int);

Note: This Question is unanswered, help us to find answer for this one

28. What does this function do? auto buff = new char[50]; Std::memset(buff,20,50);

Answer

Correct Answer: It writes the value 20 in every memory address from buff to buff+49.

Note: This Question is unanswered, help us to find answer for this one

29. What is this expression equivalent to? A->B->C->D

Answer

Correct Answer: *(*((*A).B).C).D

Note: This Question is unanswered, help us to find answer for this one

30. What is an appropriate way of removing my_object as shown below? my_class *my_object = new my_class();

Answer

Correct Answer: Delete(my_object);

Note: This Question is unanswered, help us to find answer for this one

31. What is the assumed type of a constant represented in the source code as 0.44?

Answer

Correct Answer: Double

Note: This Question is unanswered, help us to find answer for this one

32. 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;}

Answer

Correct Answer: The variable cannot be modified by any part of the code in the same application or thread. However, other threads may modify it.

Note: This Question is unanswered, help us to find answer for this one

33. What would be the output of this code? int32_t nums[3]={2,4,3}; std::cout << ( nums[0] << nums[1] << nums[2] );

Answer

Correct Answer: 256

Note: This Question is unanswered, help us to find answer for this one

34. What's wrong with this definition when using a pre-C++11 compiler?

Answer

Correct Answer: >> is parsed as the shift-right operator, and thus results in a compile error.

Note: This Question is unanswered, help us to find answer for this one

35. What does this part of a main.cpp file do? #include "library.h"

Answer

Correct Answer: It causes the replacement of the #include directive by the entire contents of the source file library.h. This is similar to a Copy-Paste operation of library.h into main.cpp.

Note: This Question is unanswered, help us to find answer for this one

36. How can C++ code call a C function?

Answer

Correct Answer: By using extern "C"

Note: This Question is unanswered, help us to find answer for this one

37. What is the .* operator and what does it do?

Answer

Correct Answer: It is the pointer to member operator, and it allows you to access a member of an object through a pointer to that specific class member.

Note: This Question is unanswered, help us to find answer for this one

38. Which statement is true?

Answer

Correct Answer: C++ supports multiple inheritance.

Note: This Question is unanswered, help us to find answer for this one

39. What is the difference between a public and a private class member?

Answer

Correct Answer: Public members can be accessed by any function. Private members can be accessed only by the same class's member functions and the friends of the class.

Note: This Question is unanswered, help us to find answer for this one

40. What is the output of this code? printf("1/2 = %f",(float)(1/2));

Answer

Correct Answer: 1/2 = 0.000000

Note: This Question is unanswered, help us to find answer for this one

41. What is the output of this code? int c=3; char d='A'; std::printf("c is %d and d is %c",c,d);

Answer

Correct Answer: C is 3 and d is A

Note: This Question is unanswered, help us to find answer for this one

42. What is true about the variable named ptr? void *ptr;

Answer

Correct Answer: It is a pointer to a value with no specific type, so it may be cast to point to any type.

Note: This Question is unanswered, help us to find answer for this one

43. What is the meaning of the three sections specified between parentheses in a for loop separated by semicolons?

Answer

Correct Answer: The first is the initialization block, the second is the condition to iterate, and the third is the increment block.

Note: This Question is unanswered, help us to find answer for this one

44. What is the meaning of the two parts specified between parentheses in a range-based for loop, separated by a colon?

Answer

Correct Answer: The first is a variable declaration that will hold an element in a sequence. The second is the sequence to traverse.

Note: This Question is unanswered, help us to find answer for this one

45. What is the ternary operator equivalent to this code snippet? if(x) y=a; else y=b;

Answer

Correct Answer: Y=x?a:b;

Note: This Question is unanswered, help us to find answer for this one

46. A class template is a _?

Answer

Correct Answer: Class written with the generic programming paradigm, specifying behavior in terms of type parameter rather than specific type.

Note: This Question is unanswered, help us to find answer for this one

47. What does auto type specifier do in this line of code (since C++11)? auto x = 4000.22;

Answer

Correct Answer: It specifies that the type of x will be deduced from the initializer - in this case, double.

Note: This Question is unanswered, help us to find answer for this one

48. What is an lvalue?

Answer

Correct Answer: It's an expression that represents an object with an address.

Note: This Question is unanswered, help us to find answer for this one

49. Which of the following is not a difference between a class and a struct?

Answer

Correct Answer: Classes may have member functions; structs are private.

Note: This Question is unanswered, help us to find answer for this one

50. Which of the following operators is overloadable?

Answer

Correct Answer: New

Note: This Question is unanswered, help us to find answer for this one

51. 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);

Answer

Correct Answer: The argument is passed as a reference, so if the passed my_array object is large, the program will require less time and memory.

Note: This Question is unanswered, help us to find answer for this one

52. Which of the following is a true statement about the difference between pointers and iterators?

Answer

Correct Answer: Incrementing an iterator always means access the next element in the container(if any), no matter the container. Incrementing the pointer means pointing to the next element in memory, not always the next element.

Note: This Question is unanswered, help us to find answer for this one

53. 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;

Answer

Correct Answer: If the code uses a function defined in two different libraries with the same prototype but possibly with different implementations, there will be a compilation error due to ambiguity.

Note: This Question is unanswered, help us to find answer for this one

54. A variable listed in a header is known as a(n) ____ parameter.

Answer

Correct Answer: Actual; formal

Note: This Question is unanswered, help us to find answer for this one

55. A for loop is considered a(n) ________ loop.

Answer

Correct Answer: Post-test

Note: This Question is unanswered, help us to find answer for this one

56. A ______ is a symbol used to represent a location in memory.

Answer

Correct Answer: Variable

Note: This Question is unanswered, help us to find answer for this one

57. In c++, :: is called the scope ____ operator.

Answer

Correct Answer: Resolution

Note: This Question is unanswered, help us to find answer for this one

58. Each node of a singly linked list has two components: ____ and ____.

Answer

Correct Answer: Info; link

Note: This Question is unanswered, help us to find answer for this one

59. Dynamic memory allocation occurs ________.

Answer

Correct Answer: When a new variable is created at runtime

Note: This Question is unanswered, help us to find answer for this one

60. Another term for repetition structures is __________

Answer

Correct Answer: Loop

Note: This Question is unanswered, help us to find answer for this one

61. _____ are programs that test code to ensure that it contains no syntax errors.

Answer

Correct Answer: Validators

Note: This Question is unanswered, help us to find answer for this one

62. You can use the ____ operator to increment or decrement the value of an enumeration type.

Answer

Correct Answer: Cast

Note: This Question is unanswered, help us to find answer for this one

63. When you write a program that stores a value in a variable, you are using ____ storage.

Answer

Correct Answer: Temporary

Note: This Question is unanswered, help us to find answer for this one

64. Data types that are created by the programmer are known as ________.

Answer

Correct Answer: Abstract data types (ADTs)

Note: This Question is unanswered, help us to find answer for this one

65. Data sent by a program to the screen, a printer, or a file is __________.

Answer

Correct Answer: Output

Note: This Question is unanswered, help us to find answer for this one

66. An example of a floating point data type is ____.

Answer

Correct Answer: Double

Note: This Question is unanswered, help us to find answer for this one

67. In c++, ____ is called the scope resolution operator.

Answer

Correct Answer: ::

Note: This Question is unanswered, help us to find answer for this one

68. ________ members of a base class are never accessible to a derived class.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

69. ________ are data items whose values cannot change while the program is running.

Answer

Correct Answer: Literals

Note: This Question is unanswered, help us to find answer for this one

70. When the ________ is placed in front of a variable name, it returns the address of that variable.

Answer

Correct Answer: Ampersand ( & )

Note: This Question is unanswered, help us to find answer for this one

71. When ____ are introduced in a program, they are immediately given a value.

Answer

Correct Answer: Module variables

Note: This Question is unanswered, help us to find answer for this one

72. The class dclass is derived from the class bclass using the ____ type of inheritance.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

73. The class ____ is the base of the classes designed to handle exceptions.

Answer

Correct Answer: Runtime_error

Note: This Question is unanswered, help us to find answer for this one

74. The ____ operator can be used to return the address of a private data member of a class.

Answer

Correct Answer: Address of

Note: This Question is unanswered, help us to find answer for this one

75. The ____ loop provides three actions in one compact statement.

Answer

Correct Answer: For

Note: This Question is unanswered, help us to find answer for this one

76. Objects both in the real world and in object-oriented programming contain ____ and methods.

Answer

Correct Answer: Attributes

Note: This Question is unanswered, help us to find answer for this one

77. Object-oriented programmers sometimes say an object is one ____ of a class.

Answer

Correct Answer: Instantiation

Note: This Question is unanswered, help us to find answer for this one

78. In some programming languages, ___________ are implemented as arrays whose elements are characters.

Answer

Correct Answer: Strings

Note: This Question is unanswered, help us to find answer for this one

79. Classes can create new classes from existing classes. this important feature ____.

Answer

Correct Answer: Encourages code reuse

Note: This Question is unanswered, help us to find answer for this one

80. A ________ search uses a loop to sequentially step through an array.

Answer

Correct Answer: Linear.

Note: This Question is unanswered, help us to find answer for this one

81. A ____ exception occurs when code attempts to divide a number by zero.

Answer

Correct Answer: Divide by Zero

Note: This Question is unanswered, help us to find answer for this one

82. A ____ defines the name and data type of program variables.

Answer

Correct Answer: Data declaration

Note: This Question is unanswered, help us to find answer for this one

83. The value of the expression 17 % 7 is ____.

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

84. The __________ function returns the smallest integer that is greater than or equal to the number.

Answer

Correct Answer: Cell

Note: This Question is unanswered, help us to find answer for this one

85. A subscript is a(n) _____.

Answer

Correct Answer: Number that indicates the position of an array element

Note: This Question is unanswered, help us to find answer for this one

86. The ________ function concatenates the contents of one c-string with another c-string.

Answer

Correct Answer: Strcat

Note: This Question is unanswered, help us to find answer for this one

87. Data that is sorted in ascending order is ordered ________.

Answer

Correct Answer: From lowest to highest value

Note: This Question is unanswered, help us to find answer for this one

88. To arrange the elements in an array in ascending order, you use the ____ method.

Answer

Correct Answer: Array.Sort

Note: This Question is unanswered, help us to find answer for this one

89. The maximum number of entry points that any programming structure can have is ____.

Answer

Correct Answer: One.

Note: This Question is unanswered, help us to find answer for this one

90. The function eof is a member of the data type ____________________.

Answer

Correct Answer: Istream

Note: This Question is unanswered, help us to find answer for this one

91. The standard header file for the abs(x)function is ____.

Answer

Correct Answer:

Note: This Question is unanswered, help us to find answer for this one

92. Before using the data type string, the program must include the header file ____.

Answer

Correct Answer: String

Note: This Question is unanswered, help us to find answer for this one

93. C++ provides a header file called ____________________, which is used for file i/o.

Answer

Correct Answer: Fstream

Note: This Question is unanswered, help us to find answer for this one

94. The header file is also known as the ____________________.

Answer

Correct Answer: Interface file

Note: This Question is unanswered, help us to find answer for this one

95. To use the strlen function in a program, you must also write #include ________.

Answer

Correct Answer:

Note: This Question is unanswered, help us to find answer for this one

96. If you try to add a new item to a full stack, the resulting condition is called a(n) ____.

Answer

Correct Answer: Overflow

Note: This Question is unanswered, help us to find answer for this one

97. A function prototype is ____.

Answer

Correct Answer: A declaration, but not a definition

Note: This Question is unanswered, help us to find answer for this one

98. To correctly swap two values, you create a(n) ____ variable to hold one of the values.

Answer

Correct Answer: Temporary

Note: This Question is unanswered, help us to find answer for this one

99. An array name and index are separated using ____.

Answer

Correct Answer: Square brackets.

Note: This Question is unanswered, help us to find answer for this one

100. A(n) ________ search is more efficient than a(n) ________ search

Answer

Correct Answer: Binary, linear.

Note: This Question is unanswered, help us to find answer for this one

101. You may use a pointer to a structure as a ________.

Answer

Correct Answer: All of these.

Note: This Question is unanswered, help us to find answer for this one

102. The \ operator is the arithmetic operator for ____ division.

Answer

Correct Answer: Integer

Note: This Question is unanswered, help us to find answer for this one

103. The percent sign is the ____ operator.

Answer

Correct Answer: Remainder

Note: This Question is unanswered, help us to find answer for this one

104. You can use either a(n) ___ variable or a bool variable to store the value of a logical expression.

Answer

Correct Answer: Int

Note: This Question is unanswered, help us to find answer for this one

105. Pseudocode uses the end-structure statement ____ to clearly show where the structure ends.

Answer

Correct Answer: Endif

Note: This Question is unanswered, help us to find answer for this one

106. If a recursive function does not contain a base case, it ________.

Answer

Correct Answer: Uses up all available stack memory, causing the program to crash

Note: This Question is unanswered, help us to find answer for this one

107. You must have a(n) ________ for every variable you include in a program.

Answer

Correct Answer: Definition

Note: This Question is unanswered, help us to find answer for this one

108. You may define a(n) ________ in the initialization expression of a for loop.

Answer

Correct Answer: Variable

Note: This Question is unanswered, help us to find answer for this one

109. Writing a program in a language such as c++ or java is known as _______ the program.

Answer

Correct Answer: Coding

Note: This Question is unanswered, help us to find answer for this one

110. The constructor function's return type is ________.

Answer

Correct Answer: None of these

Note: This Question is unanswered, help us to find answer for this one

111. The ________ sort usually performs more exchanges than the ________ sort.

Answer

Correct Answer: Selection, bubble

Note: This Question is unanswered, help us to find answer for this one

112. The ________ of a variable is limited to the block in which it is declared.

Answer

Correct Answer: Scope

Note: This Question is unanswered, help us to find answer for this one

113. Regardless of the algorithm being used, a search through an array is always performed ________.

Answer

Correct Answer: None of these

Note: This Question is unanswered, help us to find answer for this one

114. A(n) ________ search uses a loop to sequentially step through an array.

Answer

Correct Answer: Linear.

Note: This Question is unanswered, help us to find answer for this one

115. A sorting algorithm can be used to arrange a set of ________ in ________ order.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

116. A ________ file is like a stream of data that must be read from its beginning to its end.

Answer

Correct Answer: Sequential access

Note: This Question is unanswered, help us to find answer for this one

117. ________ functions are dynamically bound by the compiler.

Answer

Correct Answer: Virtual.

Note: This Question is unanswered, help us to find answer for this one

118. Dividing a problem into smaller subproblems is called ____ design

Answer

Correct Answer: Structured

Note: This Question is unanswered, help us to find answer for this one

119. Popping an element from an empty stack is called ____.

Answer

Correct Answer: Underflow

Note: This Question is unanswered, help us to find answer for this one

120. You may define a __________ in the initialization expression of a for loop.

Answer

Correct Answer: Variable.

Note: This Question is unanswered, help us to find answer for this one

121. You can assign the value of one struct variable to another struct variable of ____ type.

Answer

Correct Answer: The same

Note: This Question is unanswered, help us to find answer for this one

122. When a copy of a variable is sent to a method, it is passed by ____.

Answer

Correct Answer: Value

Note: This Question is unanswered, help us to find answer for this one

123. To use the assert function in your program, you should include the statement ____.

Answer

Correct Answer: #include

Note: This Question is unanswered, help us to find answer for this one

124. To compare struct variables, you compare them ____.

Answer

Correct Answer: Member-wise

Note: This Question is unanswered, help us to find answer for this one

125. The memory allocated for a float value is ____ bytes.

Answer

Correct Answer: Four

Note: This Question is unanswered, help us to find answer for this one

126. String constants and _____ refer to the same concept.

Answer

Correct Answer: String literals

Note: This Question is unanswered, help us to find answer for this one

127. A(n) ____ is a numeric variable used for adding together something.

Answer

Correct Answer: Accumulator

Note: This Question is unanswered, help us to find answer for this one

128. A ___________ is a member function that is automatically called when a class object is ___________.

Answer

Correct Answer: Constructor, created

Note: This Question is unanswered, help us to find answer for this one

129. A ________ value in a loop can be either a positive or a negative number.

Answer

Correct Answer: Step

Note: This Question is unanswered, help us to find answer for this one

130. ________ functions may have the same name, as long as their parameter lists are different.

Answer

Correct Answer: Two or more

Note: This Question is unanswered, help us to find answer for this one

131. ____ are arrays that have more than one dimension.

Answer

Correct Answer: Multidimensional arrays

Note: This Question is unanswered, help us to find answer for this one

132. C++ requires that a copy constructor's parameter be a(n) ________.

Answer

Correct Answer: Reference object

Note: This Question is unanswered, help us to find answer for this one

133. ____ are executable statements that inform the user what to do.

Answer

Correct Answer: Promp Lines

Note: This Question is unanswered, help us to find answer for this one

134. In c++, the dot is an operator called the ____ operator.

Answer

Correct Answer: Member access

Note: This Question is unanswered, help us to find answer for this one

135. To test whether a character is a numeric digit character, use the ________ function.

Answer

Correct Answer: Isdigit

Note: This Question is unanswered, help us to find answer for this one

136. The scope of a namespace member is local to the ____.

Answer

Correct Answer: Namespace

Note: This Question is unanswered, help us to find answer for this one

137. The name of the function to overload the operator <= is ____.

Answer

Correct Answer: <=operator

Note: This Question is unanswered, help us to find answer for this one

138. The first step in using the string class is to #include the ________ header file.

Answer

Correct Answer: String

Note: This Question is unanswered, help us to find answer for this one

139. The _____ of an identifier refers to where in the program an identifier is accessible.

Answer

Correct Answer: Scope

Note: This Question is unanswered, help us to find answer for this one

140. In the swap module, the third variable is declared as a ________ variable.

Answer

Correct Answer: Local

Note: This Question is unanswered, help us to find answer for this one

141. Arrays may be ________ at the time they are ________.

Answer

Correct Answer: Initialized, declared

Note: This Question is unanswered, help us to find answer for this one

142. A(n) ________ operator can work with programmer-defined data types.

Answer

Correct Answer: Overloaded

Note: This Question is unanswered, help us to find answer for this one

143. A(n) ________ informs the compiler that a class will be declared later in the program.

Answer

Correct Answer: Forward declaration

Note: This Question is unanswered, help us to find answer for this one

144. A file must be ________ before data can be written to or read from it.

Answer

Correct Answer: Opened

Note: This Question is unanswered, help us to find answer for this one

145. To use files in a c++ program you must include the ________ header file.

Answer

Correct Answer: Fstream

Note: This Question is unanswered, help us to find answer for this one

146. The conditional operator ?: takes ____ arguments.

Answer

Correct Answer: Three

Note: This Question is unanswered, help us to find answer for this one

147. The following statement ________. int *ptr = new int;

Answer

Correct Answer: Assigns an address to the variable ptr

Note: This Question is unanswered, help us to find answer for this one

148. With pointer variables, you can __________ manipulate data stored in other variables.

Answer

Correct Answer: Indirectly

Note: This Question is unanswered, help us to find answer for this one

149. When you work with a dereferenced pointer, you are actually working with ________.

Answer

Correct Answer: The actual value of the variable whose address is stored in the pointer variable

Note: This Question is unanswered, help us to find answer for this one

150. When you dereference an object pointer, use the ________.

Answer

Correct Answer: -> operator

Note: This Question is unanswered, help us to find answer for this one

151. When one control statement is located within another, it is said to be ____.

Answer

Correct Answer: Nested

Note: This Question is unanswered, help us to find answer for this one

152. The value of the expression 33/10, assuming both values are integral data types, is ____.

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

153. The primary outcome of the systems analysis phase is ____.

Answer

Correct Answer: A prioritized list of system requirements

Note: This Question is unanswered, help us to find answer for this one

154. The ________ constructor is called before the ________ constructor.

Answer

Correct Answer: Base, derived

Note: This Question is unanswered, help us to find answer for this one

155. Manipulators without parameters are part of the ____ header file.

Answer

Correct Answer: Iostream

Note: This Question is unanswered, help us to find answer for this one

156. In an adt the implementation details are ________ the interface through which a program uses it.

Answer

Correct Answer: Kept separate from

Note: This Question is unanswered, help us to find answer for this one

157. In a ____ copy, two or more pointers have their own data.

Answer

Correct Answer: Deep

Note: This Question is unanswered, help us to find answer for this one

158. If you leave out the size declarator in an array declaration ________.

Answer

Correct Answer: The correct answer is: you must furnish an initialization list

Note: This Question is unanswered, help us to find answer for this one

159. An array created during the execution of a program is called a(n) ____ array.

Answer

Correct Answer: Dynamic

Note: This Question is unanswered, help us to find answer for this one

160. A(n) ____ is a programmer-defined type, such as a class.

Answer

Correct Answer: Abstract data type

Note: This Question is unanswered, help us to find answer for this one

161. A two-dimensional array is like ______________ put together.

Answer

Correct Answer: Several identical arrays.

Note: This Question is unanswered, help us to find answer for this one

162. A loop that continues to execute endlessly is called a(n) ____ loop.

Answer

Correct Answer: Infinite

Note: This Question is unanswered, help us to find answer for this one

163. A class is a(n) ________ that is defined by the programmer.

Answer

Correct Answer: Data type

Note: This Question is unanswered, help us to find answer for this one

164. ____ loops are called posttest loops.

Answer

Correct Answer: Do...while loop

Note: This Question is unanswered, help us to find answer for this one

165. The expression static_cast(6.9) + static_cast(7.9) evaluates to ____.

Answer

Correct Answer: 13

Note: This Question is unanswered, help us to find answer for this one

166. A(n) ____ consists of data and the operations on those data.

Answer

Correct Answer: Object

Note: This Question is unanswered, help us to find answer for this one

167. The value in a(n) ________ variable persists between function calls.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

168. Use the delete operator only on pointers that were ________.

Answer

Correct Answer: Created with the new operator

Note: This Question is unanswered, help us to find answer for this one

169. The programming language c++ evolved from ____.

Answer

Correct Answer: C

Note: This Question is unanswered, help us to find answer for this one

170. To pass an array as an argument to a function, pass the _________ of the array.

Answer

Correct Answer: Name

Note: This Question is unanswered, help us to find answer for this one

171. To access an array element, use the array name and the element's ________.

Answer

Correct Answer: Subscript

Note: This Question is unanswered, help us to find answer for this one

172. The std::endl stream manipulator________.

Answer

Correct Answer: Outputs a newline and flushes the output buffer

Note: This Question is unanswered, help us to find answer for this one

173. The statements that may generate an exception are placed in a ____ block.

Answer

Correct Answer: Try

Note: This Question is unanswered, help us to find answer for this one

174. The statement: return 8, 10; returns the value ____.

Answer

Correct Answer: 10

Note: This Question is unanswered, help us to find answer for this one

175. The ideal type of loop to use if you want a user to enter exactly 20 values is a(n) ________ loop.

Answer

Correct Answer: For

Note: This Question is unanswered, help us to find answer for this one

176. The heading of the function is also called the ____.

Answer

Correct Answer: Function header

Note: This Question is unanswered, help us to find answer for this one

177. The expression x < y is called a(n) ________ expression.

Answer

Correct Answer: Relational

Note: This Question is unanswered, help us to find answer for this one

178. The do-while loop is a(n) ________ loop, whereas the while loop is a(n) ________ loop.

Answer

Correct Answer: Post test, pretest

Note: This Question is unanswered, help us to find answer for this one

179. The destructor function's return type is ________.

Answer

Correct Answer: Nothing. Destructors have no return type.

Note: This Question is unanswered, help us to find answer for this one

180. The conditional and operator in java, c++, and c# is ____.

Answer

Correct Answer: &&

Note: This Question is unanswered, help us to find answer for this one

181. The components of a struct are called the ____ of the struct.

Answer

Correct Answer: Members

Note: This Question is unanswered, help us to find answer for this one

182. The compiler performs ________ on virtual functions.

Answer

Correct Answer: Dynamic binding

Note: This Question is unanswered, help us to find answer for this one

183. The compiler checks ________.

Answer

Correct Answer: Syntax rule violations

Note: This Question is unanswered, help us to find answer for this one

184. The code int *p; declares p to be a(n) ____ variable.

Answer

Correct Answer: Pointer

Note: This Question is unanswered, help us to find answer for this one

185. The c++ function ____ calculates the largest whole number that is less than or equal to x.

Answer

Correct Answer: Floor(x)

Note: This Question is unanswered, help us to find answer for this one

186. The c++ ________ operator represents logical and.

Answer

Correct Answer: &&

Note: This Question is unanswered, help us to find answer for this one

187. The c-string company[12] can hold ________.

Answer

Correct Answer: Eleven characters and the null terminator

Note: This Question is unanswered, help us to find answer for this one

188. The addition and deletion of elements of a stack occurs only at the ____ of the stack.

Answer

Correct Answer: Top

Note: This Question is unanswered, help us to find answer for this one

189. The >= is one of the __________ operators.

Answer

Correct Answer: Relational operator

Note: This Question is unanswered, help us to find answer for this one

190. The -- operator ________.

Answer

Correct Answer: All the above are true

Note: This Question is unanswered, help us to find answer for this one

191. The ________, also known as the address operator, returns the memory address of a variable.

Answer

Correct Answer: Ampersand ( & )

Note: This Question is unanswered, help us to find answer for this one

192. "the ________ operator is used in c++ to test for equality.

Answer

Correct Answer: ==

Note: This Question is unanswered, help us to find answer for this one

193. The ________ of recursion is the number of times a recursive function calls itself.

Answer

Correct Answer: Depth

Note: This Question is unanswered, help us to find answer for this one

194. The ________ object enables a program to read data from the user.

Answer

Correct Answer: Std::cin

Note: This Question is unanswered, help us to find answer for this one

195. The ________ library function reverses the order of a character array.

Answer

Correct Answer: None of the answers are correct

Note: This Question is unanswered, help us to find answer for this one

196. The ________ is/are used to display information on the computer's screen.

Answer

Correct Answer: Cout object

Note: This Question is unanswered, help us to find answer for this one

197. The ________ class constructor is called before the ________ class constructor.

Answer

Correct Answer: Base, derived

Note: This Question is unanswered, help us to find answer for this one

198. The ________ and ________ operators can be used to increment or decrement a pointer variable.

Answer

Correct Answer: ++, --

Note: This Question is unanswered, help us to find answer for this one

199. The ____ members of an object form its internal state.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

200. When you derive a class from an existing class, you ________ add new data and functions.

Answer

Correct Answer: May

Note: This Question is unanswered, help us to find answer for this one

201. Polymorphism means ________.

Answer

Correct Answer: That a variable of supertype can refer to a subtype object

Note: This Question is unanswered, help us to find answer for this one

202. Multiple inheritance is when a ________ class has ________ base classes.

Answer

Correct Answer: Derived, two or more

Note: This Question is unanswered, help us to find answer for this one

203. Main memory is called ____.

Answer

Correct Answer: Random access memory

Note: This Question is unanswered, help us to find answer for this one

204. Main memory is an ordered sequence of items, called ____.

Answer

Correct Answer: Memory cells

Note: This Question is unanswered, help us to find answer for this one

205. Inheritance is an example of a(n) ____ relationship.

Answer

Correct Answer: Is-a

Note: This Question is unanswered, help us to find answer for this one

206. In memory, c++ automatically places a ________ at the end of string literals.

Answer

Correct Answer: Null terminator

Note: This Question is unanswered, help us to find answer for this one

207. In c++, virtual functions are declared using the reserved word ____.

Answer

Correct Answer: False, they are declared using

Note: This Question is unanswered, help us to find answer for this one

208. In c++, the scope resolution operator is ____.

Answer

Correct Answer: ::

Note: This Question is unanswered, help us to find answer for this one

209. In c++, the null character is represented as ____.

Answer

Correct Answer: '\0'

Note: This Question is unanswered, help us to find answer for this one

210. In c++, the ____ symbol is an operator, called the member access operator.

Answer

Correct Answer: .(dot)

Note: This Question is unanswered, help us to find answer for this one

211. In c++, ____ is called the address of operator.

Answer

Correct Answer: & or ampersand

Note: This Question is unanswered, help us to find answer for this one

212. In c++, ____ is a reserved word.

Answer

Correct Answer: Typedef

Note: This Question is unanswered, help us to find answer for this one

213. In any program that uses the cin object, you must include the ________.

Answer

Correct Answer: Iostream header file

Note: This Question is unanswered, help us to find answer for this one

214. In a(n) ____ copy, two or more pointers have their own data.

Answer

Correct Answer: Deep

Note: This Question is unanswered, help us to find answer for this one

215. In a sequence of try/catch blocks, the last catch block of that sequence should be ____.

Answer

Correct Answer: Catch(...){ }

Note: This Question is unanswered, help us to find answer for this one

216. In ____ binding, the necessary code to call a specific function is generated by the compiler.

Answer

Correct Answer: Static

Note: This Question is unanswered, help us to find answer for this one

217. If a while loop has no braces around the body of the loop ________.

Answer

Correct Answer: The loop body contains just one statement.

Note: This Question is unanswered, help us to find answer for this one

218. If a member of a class is ____, you cannot access it outside the class.

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

219. Given the statement double *p;, the statement p++; will increment the value of p by ____ byte(s).

Answer

Correct Answer: 8 bytes

Note: This Question is unanswered, help us to find answer for this one

220. Class templates are called ____ types.

Answer

Correct Answer: Parameterized

Note: This Question is unanswered, help us to find answer for this one

221. C++ automatically places ________ at the end of a string constant (string literal).

Answer

Correct Answer: Null terminator

Note: This Question is unanswered, help us to find answer for this one

222. C++ allows you to redefine the way ________ work when used with class objects.

Answer

Correct Answer: Standard operators

Note: This Question is unanswered, help us to find answer for this one

223. Before a structure variable can be created, the structure must be _________.

Answer

Correct Answer: Declared

Note: This Question is unanswered, help us to find answer for this one

224. Arrays must be ________ at the time they are ________.

Answer

Correct Answer: Initialized, declared

Note: This Question is unanswered, help us to find answer for this one

225. Array subscripts are always a sequence of ____.

Answer

Correct Answer: Integers

Note: This Question is unanswered, help us to find answer for this one

226. Array elements must be ________ before a binary search can be performed.

Answer

Correct Answer: Sorted

Note: This Question is unanswered, help us to find answer for this one

227. Arguments are passed to the base class destructor function by the ________ class ________ function.

Answer

Correct Answer: None of these

Note: This Question is unanswered, help us to find answer for this one

228. An operation that copies a value into a variable is called a(n) ________ operation.

Answer

Correct Answer: Assignment

Note: This Question is unanswered, help us to find answer for this one

229. A structure ________ contain members of the same data type.

Answer

Correct Answer: Can

Note: This Question is unanswered, help us to find answer for this one

230. A struct variable can be passed as a parameter ____.

Answer

Correct Answer: Either by value or by reference

Note: This Question is unanswered, help us to find answer for this one

231. A stack can be implemented as either a(n) ____ or a linked structure.

Answer

Correct Answer: Array

Note: This Question is unanswered, help us to find answer for this one

232. A program that tests a function is called a _____ program.

Answer

Correct Answer: Driver

Note: This Question is unanswered, help us to find answer for this one

233. A program called a(n) ____ combines the object program with the programs from libraries.

Answer

Correct Answer: Linker

Note: This Question is unanswered, help us to find answer for this one

234. A function ____________________ is a function that is not fully coded.

Answer

Correct Answer: Stub

Note: This Question is unanswered, help us to find answer for this one

235. A function ________ return a structure.

Answer

Correct Answer: May

Note: This Question is unanswered, help us to find answer for this one

236. A function ________ is a statement that causes a function to execute.

Answer

Correct Answer: Function call

Note: This Question is unanswered, help us to find answer for this one

237. A function ________ contains the statements that make up the function.

Answer

Correct Answer: Definition

Note: This Question is unanswered, help us to find answer for this one

238. A destructor has the character ____, followed by the name of the class.

Answer

Correct Answer: ~

Note: This Question is unanswered, help us to find answer for this one

239. A class ____ automatically executes whenever a class object goes out of scope.

Answer

Correct Answer: Destructor

Note: This Question is unanswered, help us to find answer for this one

240. A catch block can have, at most, ____ catch block parameter(s).

Answer

Correct Answer: One

Note: This Question is unanswered, help us to find answer for this one

241. ________ must be included in any program that uses the cout object.

Answer

Correct Answer: The header file iostream

Note: This Question is unanswered, help us to find answer for this one

242. ________ are c++ operators that change their operands by one.

Answer

Correct Answer: ++ and --

Note: This Question is unanswered, help us to find answer for this one

243. ____ consists of 65,536 characters.

Answer

Correct Answer: Unicode

Note: This Question is unanswered, help us to find answer for this one

244. Subscript numbering in c++________.

Answer

Correct Answer: Begins with zero

Note: This Question is unanswered, help us to find answer for this one

245. Every complete c++ program must have a __________.

Answer

Correct Answer: Function named main

Note: This Question is unanswered, help us to find answer for this one

246. An element of a two-dimensional array is referred to by ________ followed by ________.

Answer

Correct Answer: The row subscript of the element, the column subscript of the element

Note: This Question is unanswered, help us to find answer for this one

247. An array with no elements is ________.

Answer

Correct Answer: Illegal in C++

Note: This Question is unanswered, help us to find answer for this one

248. A(n) ________ can be used to specify the starting values of an array.

Answer

Correct Answer: Initialization list

Note: This Question is unanswered, help us to find answer for this one

249. A function can have zero to many parameters, and it can have ________ return value(s).

Answer

Correct Answer: Only 1

Note: This Question is unanswered, help us to find answer for this one

250. A class may have ________ default constructor(s) and ________ destructor(s).

Answer

Correct Answer: Only one, only one

Note: This Question is unanswered, help us to find answer for this one

251. A binary search begins with the ________ element of an array.

Answer

Correct Answer: Middle

Note: This Question is unanswered, help us to find answer for this one

252. ________ member function may be called by a statement in a function that is outside the class.

Answer

Correct Answer: Public

Note: This Question is unanswered, help us to find answer for this one

253. ____ is a valid char value.

Answer

Correct Answer: 'A'

Note: This Question is unanswered, help us to find answer for this one

254. ____ is a parameterized stream manipulator.

Answer

Correct Answer: setfill

Note: This Question is unanswered, help us to find answer for this one

255. Which of the following will compile, link and run OK in C++? (Choose all that apply.)

Answer

Correct Answer: class Upwork { public: Upwork(const char*){} explicit Upwork(long){} }; void f(Upwork) {} int main() { Upworkupw = "Upwork"; f("Upwork"); }
class Upwork { public: Upwork(const char*){} explicit Upwork(long){} }; void f(Upwork) {} int main() { Upworkupw(1+2); f(upw); }
class Upwork { public: Upwork(const char*); explicit Upwork(long); }; void f(Upwork) {} int main() { Upworkupw = "Upwork"; f("Upwork"); }
class Upwork { public: Upwork(const char*); explicit Upwork(long); }; void ::f(Upwork) {} int main() { Upworkupw = "Upwork"; f("Upwork"); }

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

256.

Which function cannot be overloaded?

Answer

Correct Answer: Virtual Function

Note: This Question is unanswered, help us to find answer for this one

257.

Destructor calls are made in which order of the corresponding constructor calls?

Answer

Correct Answer: Reverse order.

Note: This Question is unanswered, help us to find answer for this one

258.

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?

Answer

Correct Answer: Copy Constructor

Note: This Question is unanswered, help us to find answer for this one

259.

Which of the following is NOT provided by the compiler by default?

Answer

Correct Answer: Copy destructor

Note: This Question is unanswered, help us to find answer for this one

260.

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; }

Answer

Correct Answer: 58

Note: This Question is unanswered, help us to find answer for this one

261.

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; }

Answer

Correct Answer: 191

Note: This Question is unanswered, help us to find answer for this one

262.

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.

Answer

Correct Answer: delete[]

Note: This Question is unanswered, help us to find answer for this one

263.

C++ provides the ability to define _________ and ___________ as its primary encapsulation mechanisms.

Answer

Correct Answer: Classes, functions

Note: This Question is unanswered, help us to find answer for this one

264.

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; };

Answer

Correct Answer: 11

Note: This Question is unanswered, help us to find answer for this one

265.

How can you declare a template?

Answer

Correct Answer: template<>

Note: This Question is unanswered, help us to find answer for this one

266.

When arguments are passed to a destructor it is call a '___' error.

Answer

Correct Answer: Syntax

Note: This Question is unanswered, help us to find answer for this one

267.

Which function prototype is VALID? (Choose all that apply)

Answer

Correct Answer: int UpWork(int job = project());

Note: This Question is unanswered, help us to find answer for this one

268.

Which of the following statement is correct?

Answer

Correct Answer: The default value for an argument cannot be function call.

Note: This Question is unanswered, help us to find answer for this one

269.

How to make the C/C++ source can be built for any architecture,select proper answer?

Answer

Correct Answer: Use #ifdef/#endif macros within the source code like below #if defined(__i386__) // do something for 32bit ARCH #elif defined(__x86_64__) // do something for 64bit ARCH #endif

Note: This Question is unanswered, help us to find answer for this one

270.

Study below codes 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

Answer

Correct Answer: Read rdtsc register value for x86 and RAM data from address 0 for PowerPC architecture

Note: This Question is unanswered, help us to find answer for this one

271.

Which of the following statement is correct?

Answer

Correct Answer: Once a reference variable has been defined to refer to a particular variable it cannot refer to any other variable.

Note: This Question is unanswered, help us to find answer for this one

272.

Which of the following statement is correct?

Answer

Correct Answer: All arguments of an overloaded function can be default.

Note: This Question is unanswered, help us to find answer for this one

273.

How many types of templates are there in C++?

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

274.

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); }

Answer

Correct Answer: Execution context is different, one is executed within another thread and another is executed within the caller process
Same but different is related with the output from the execution result of

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

275.

Which of the following will compile, link and run OK in C++? (Choose all that apply.)

Answer

Correct Answer: struct B{}; struct B1:B {}; struct B2:B{}; struct C{}; struct DD :B1, B2, private C{}; int main() { DD* p = new DD; }
struct B{}; struct B1:B {}; struct B2:B{}; struct C{}; struct DD :B1, B2, private C{}; int main() { DD* p = new DD; B1* pb = p; }

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

276.

What is the maximum number of elements that can be added to a linked list?

Answer

Correct Answer: 10

Note: This Question is unanswered, help us to find answer for this one

277.

Which of the following statements are correct? Check all that apply.

Answer

Correct Answer: The stdio.h header defines variable types, macros, and functions for performing input and output.
The stdlib.h header defines variable types, macros, and functions for performing general functions.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

278.

27- Does an exception have to be caught in the same place where the try block created the exception?

Answer

Correct Answer: No
it is possible to catch an exception anywhere in the call stack

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

279.

Which of the following are valid declarations or definitions of a pointer?

Answer

Correct Answer: int* p1 = 0;
int* p2 = 2-2;
int* p6 = new int;

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

280.

Which of the following statements are true about conversions in C++? (Choose all that apply.)

Answer

Correct Answer: Any pointer to an object type can be implicitly converted to a void*.
When a floating-point is converted to an integer value, the fractional part is discarded.
Conversions from integer to floating types are as mathematically correct as the hardware allows.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

281.

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'; }

Answer

Correct Answer: f(3): Hourly s: Fixed r: Freelancers

Note: This Question is unanswered, help us to find answer for this one

282.

Consider the following code: <font size=2> template<class T> void Kill(T *&objPtr) { delete

objPtr; objPtr = NULL; } class MyClass { }; void Test() { MyClass *ptr = new MyClass();

Kill(ptr); Kill(ptr); } </font> Invoking Test() will cause which of the following? 

Answer

Correct Answer: Code will execute properly

Note: This Question is unanswered, help us to find answer for this one

283.

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

Answer

Correct Answer: Have to send SIGSTOP/SIGCONT like below Kill(12345, SIGSTOP) intmem_file = open(“/proc/12345/mem”, O_RDONLY); … close(mem_file); kill(12345, SIGCONT);

Note: This Question is unanswered, help us to find answer for this one

284.

Which of the following is the correct way to declare a function as constant?

Answer

Correct Answer: funcshowData(void) const { }

Note: This Question is unanswered, help us to find answer for this one

285.

Which of the following is the better 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)

Answer

Correct Answer: B

Note: This Question is unanswered, help us to find answer for this one

286.

Reference is like a ____.

Answer

Correct Answer: Pointer

Note: This Question is unanswered, help us to find answer for this one

287.

What is the value of a following the below sequence of C++ statements? int a = 7; int& r = a; r = 8;

Answer

Correct Answer: 8

Note: This Question is unanswered, help us to find answer for this one

288.

Consider the following C++ definition: int* x = 0; Which of the following expressions refers to the location of the variable x in memory?

Answer

Correct Answer: &x

Note: This Question is unanswered, help us to find answer for this one

289.

What does the following code? while (numforks<maxf) { pid_tpid = fork(); if (pid == 0) { //do something exit(1); } else { numforks++; } while (numforks>= maxf) { wait(NULL); numforks--; } }

Answer

Correct Answer: Creates Maximum maxf child processes and wait until they are finished

Note: This Question is unanswered, help us to find answer for this one

290.

Which operator is used to deallocate the memory?

Answer

Correct Answer: None of the above.

Note: This Question is unanswered, help us to find answer for this one

291.

Which of the following you can use pass an array object to a function?

Answer

Correct Answer: void SomeFunction(Array&);

Note: This Question is unanswered, help us to find answer for this one

292.

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?

Answer

Correct Answer: uninitialized

Note: This Question is unanswered, help us to find answer for this one

293.

When your program allocates memory on the free store, a _____ is returned?

Answer

Correct Answer: pointer

Note: This Question is unanswered, help us to find answer for this one

294.

What is the output of following code? #include <iostream> using namespace std; void Upwork(); int main() { try { Upwork(); } catch(double) { cerr<< "Projects" <<endl; } return 0; } void Upwork() { throw 3; }

Answer

Correct Answer: Running the code gives an unhandled exception.

Note: This Question is unanswered, help us to find answer for this one

295.

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; };

Answer

Correct Answer: 15

Note: This Question is unanswered, help us to find answer for this one

296.

What will be the output of following program? #include <iostream> using namespace std; int main() { char* upwork; try { upwork = new char[1024]; if (upwork == 0) throw "Projects"; else cout<<sizeof(upwork) << "Freelancers"<<endl; } catch(char *strg) { cout<<"Feedback"<<strg<<endl; } return 0; }

Answer

Correct Answer: It depends on the size of the data type.

Note: This Question is unanswered, help us to find answer for this one

297.

What is a template?

Answer

Correct Answer: A template is a formula for creating a generic class.

Note: This Question is unanswered, help us to find answer for this one

298.

C++ ____ for local variables are called at the end of the object lifetime?

Answer

Correct Answer: Classes

Note: This Question is unanswered, help us to find answer for this one

299.

What does the function objects implement?

Answer

Correct Answer: operator()

Note: This Question is unanswered, help us to find answer for this one

300.

Function overloading is an example of ___?

Answer

Correct Answer: polymorphism

Note: This Question is unanswered, help us to find answer for this one

301.

Compare below source codes and tell which one is better?

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 <buffer_size - len; j++) { for (int k = 0; k <len; k++){ if ((char)buffer[j+k] != (char)malware_pattern[i][k]) break; } // found malware pattern if (k == len) return 1; } } return 0; } B) 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 <buffer_size - len; j++) { if (strstr(buffer, (void*) malware_pattern[i]) != NULL) { // found malware pattern return 1; } } } return 0; }

Answer

Correct Answer: B) function is better

Note: This Question is unanswered, help us to find answer for this one

302.

Which symbol is used to declare the preprocessor directives?

Answer

Correct Answer: #

Note: This Question is unanswered, help us to find answer for this one

303.

A reference is declared using ___ symbol?

Answer

Correct Answer: &

Note: This Question is unanswered, help us to find answer for this one

304.

Which of the following is a valid statement regarding cin.read()?

Answer

Correct Answer: Reads n bytes (or until the end of the file) from the stream into the buffer.

Note: This Question is unanswered, help us to find answer for this one

305.

Functions can be declared to return a reference type. Which of the following are correct reasons to make such a declaration? (Choose all that apply)

Answer

Correct Answer: The information being returned is a large enough object that returning a reference is more efficient than returning a copy.
The type of the function is an rvalue.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

306.

A reference is stored on ___.

Answer

Correct Answer: stack.

Note: This Question is unanswered, help us to find answer for this one

307.

What is the output if following code executed? 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; }

Answer

Correct Answer: 10

Note: This Question is unanswered, help us to find answer for this one

308.

Which operator is used to resolve the scope of the global variable?

Answer

Correct Answer: ::

Note: This Question is unanswered, help us to find answer for this one

309.

Which of the following statement is correct about the references?

Answer

Correct Answer: A reference must always be initialized.

Note: This Question is unanswered, help us to find answer for this one

310.

How many adapters support the checked iterators?

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

311.

What are the names of default standard streams in C++?

Answer

Correct Answer: cin
cout
cerr

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

312.

Which of the following is TRUE? (Choose all that apply)

Answer

Correct Answer: Changing a reference changes the referent.

Note: This Question is unanswered, help us to find answer for this one

313.

Which of the following is true? (Choose all that apply)

Answer

Correct Answer: Once a variable and a reference are linked, they are tied together.
A global variable can be returned by reference.
A local variable may not be returned by reference.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

314.

What is the output of following program? #include <iostream> using namespace std; int main() { int i, j; j = 0; i = (j++, j + 1, 2 + j); cout << i; return 0; }

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

315.

What is the output of the following? #include <iostream> 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; }

Answer

Correct Answer: 3933

Note: This Question is unanswered, help us to find answer for this one

316.

What will be the output of following code:- #include <iostream> using namespace std; int main() { int a = 1, b = 2, c, d; c = a, b; d = (a, b); cout << c << ' ' << d; return 0; }

Answer

Correct Answer: 1 2

Note: This Question is unanswered, help us to find answer for this one

317.

Which of the following gets called when an object goes out of scope?

Answer

Correct Answer: Destructor

Note: This Question is unanswered, help us to find answer for this one

318.

Which of the following access specifier is used in a class definition by default?

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

319.

Which of the following statement is incorrect?

Answer

Correct Answer: The default arguments are given in the function prototype and should be repeated in the function definition.

Note: This Question is unanswered, help us to find answer for this one

320.

To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator ___.

Answer

Correct Answer: delete[]

Note: This Question is unanswered, help us to find answer for this one

321.

What is a function template?

Answer

Correct Answer: creating a function without having to specify the exact type.

Note: This Question is unanswered, help us to find answer for this one

322.

Which of the following type of data member can be shared by all instances of a class?

Answer

Correct Answer: static

Note: This Question is unanswered, help us to find answer for this one

323.

Which of the following keywords is used to control access to a class member?

Answer

Correct Answer: Protected

Note: This Question is unanswered, help us to find answer for this one

324.

How many objects can be created from an abstract class?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

325.

Which of the following statements is/are correct?

Answer

Correct Answer: A constructor of a derived class can access any public and protected member of the base class.
Constructor cannot be inherited but the derived class can call them.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

326.

Which of the following is true about destructors?

Answer

Correct Answer: A destructor has no return type.

Note: This Question is unanswered, help us to find answer for this one

327.

Destructor has the same name as constructor and it is preceded by ___?

Answer

Correct Answer: ~

Note: This Question is unanswered, help us to find answer for this one

328.

If a copy constructor receives its arguments by-value, the copy constructor will ____.

Answer

Correct Answer: call itself recursively.

Note: This Question is unanswered, help us to find answer for this one

329.

A constructor that accepts ____ parameters is called default constructor.

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

330.

Which constructor function is designed to copy objects of the same class type?

Answer

Correct Answer: copy constructor

Note: This Question is unanswered, help us to find answer for this one

331.

Which of the following statements are correct? (Choose all that apply)

Answer

Correct Answer: Constructor has the same name as that of the class.
Destructor has the same name as that of the class with a tilde symbol at the beginning.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

332.

What does container adapter provide to interface?

Answer

Correct Answer: Restricted interface

Note: This Question is unanswered, help us to find answer for this one

333.

Which of the following is true in relation to destructors for automatic objects if a program terminates with a call to a function exit?

Answer

Correct Answer: They are not called.

Note: This Question is unanswered, help us to find answer for this one

334.

Which of the following is not a type of constructor?

Answer

Correct Answer: Friend constructor

Note: This Question is unanswered, help us to find answer for this one

335.

Void pointer can point to which type of objects?

Answer

Correct Answer: All of the above.

Note: This Question is unanswered, help us to find answer for this one

336.

How many default constructors per class are possible?

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

337.

Which is used to create a pure Virtual function?

Answer

Correct Answer: =0

Note: This Question is unanswered, help us to find answer for this one

338.

To which type of class we can apply RTTI?

Answer

Correct Answer: Polymorphic

Note: This Question is unanswered, help us to find answer for this one

339.

The pointer which stores the current active object address is ___

Answer

Correct Answer: this

Note: This Question is unanswered, help us to find answer for this one

340.

Copy constructor must receive its arguments by ___?

Answer

Correct Answer: only pass-by-reference

Note: This Question is unanswered, help us to find answer for this one

341.

Which of the following members are not accessed by using the direct member access operator?

Answer

Correct Answer: protected

Note: This Question is unanswered, help us to find answer for this one

342.

The stream ‘cout’ is by default connected to console output ___.

Answer

Correct Answer: Device

Note: This Question is unanswered, help us to find answer for this one

343.

Which of the following storage classes are supported in C++?

Answer

Correct Answer: auto and static
extern

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

344.

Which operator is used to allocate memory?

Answer

Correct Answer: new

Note: This Question is unanswered, help us to find answer for this one

345.

Runtime polymorphism is achieved only when a virtual function is accessed through a ____ to the base class.

Answer

Correct Answer: Pointer

Note: This Question is unanswered, help us to find answer for this one

346.

How many number of arguments can a destructor of a class receives?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

347.

What happens when a handler is not found for a given exception?

Answer

Correct Answer: A call is made to the standard library function terminate().

Note: This Question is unanswered, help us to find answer for this one

348.

Which of the following is not a member of a class?

Answer

Correct Answer: Friend function

Note: This Question is unanswered, help us to find answer for this one

349.

Which of the following statement is correct? (Choose all that apply)

Answer

Correct Answer: C++ permits the defining of functions taking constants as an argument.
Where function arguments are declared as constant, these arguments can not be changed.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

350.

Which of the following statements are true? (Choose all that apply.)

Answer

Correct Answer: The expression ... p -> m ... is equivalent to ... (*p).m
The expression ... p[x] .... is equivalent to ... *(p+x)
The expression ... v++ ... is equivalent to ... v+=1

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

351.

Which of the following are TRUE? (Choose all that apply)

Answer

Correct Answer: Default arguments can be provided for pointers to functions.
A function cannot have all its arguments as default.

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

352.

Which of the following types of inheritance supported in C++?

Answer

Correct Answer: Single
Multilevel
Multiple
Hierarchical
Hybrid

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

353.

Consider the sample code given below and 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?

Answer

Correct Answer: There will be an error because in the declaration of innerObject the type Inner must be qualified by Outer

Note: This Question is unanswered, help us to find answer for this one

354.

Consider the sample code given below and 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?

Answer

Correct Answer: To ensure that correct destructor is called when p is deleted

Note: This Question is unanswered, help us to find answer for this one

355.

Consider the following code:
#include<iostream>
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?

Answer

Correct Answer: Constructor of A Constructor of B Destructor of B Destructor of A

Note: This Question is unanswered, help us to find answer for this one

356.

What will happen when the following code is compiled and executed?
#include<iostream>
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;
}

Answer

Correct Answer: The printed output will be 5

Note: This Question is unanswered, help us to find answer for this one

357.

Which of the following member functions can be used to add an element in
an std::vector?

Answer

Correct Answer: push_back

Note: This Question is unanswered, help us to find answer for this one

358.

What will be the 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;
}

Answer

Correct Answer: In second 1 In first 2

Note: This Question is unanswered, help us to find answer for this one

359.

If input and output operations have to be performed on a file, an object of
the _______ class should be created.

Answer

Correct Answer: fstream

Note: This Question is unanswered, help us to find answer for this one

360.

Which of the following STL classes is deprecated (i.e should no longer be
used)?

Answer

Correct Answer: ostrstream

Note: This Question is unanswered, help us to find answer for this one

361.

which of the following is true.

Answer

Correct Answer: All of the above

Note: This Question is unanswered, help us to find answer for this one

362.

No, var1 and var2 are not functions but are variables

Answer

Correct Answer: ad
fail

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

363.

In the given sample Code, is the constructor definition valid?
class someclass
{
int var1, var2;
public:
someclass(int num1, int num2) : var1(num1), var2(num2)
{
}
};

Answer

Correct Answer: Yes, it is valid

Note: This Question is unanswered, help us to find answer for this one

364.

Consider the following class hierarchy:
class Base
{ }
class Derived : public Base
{ }
Which of the following are true?

Answer

Correct Answer: Derived can access public and protected member functions of Base
The following line of code is valid: Base *object = new Derived();

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

365.

Consider the sample code given below and 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?

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

366.

What is the output of the following code segment?
int n = 9;
int *p;
p=&n;
n++;
cout << *p+2 << "," << n;

Answer

Correct Answer: 12,10

Note: This Question is unanswered, help us to find answer for this one

367.

Which of the following are true about class and struct in C++:

Answer

Correct Answer: A class can have inheritance but a struct cannot
In a class all members are private by default, whereas in struct all members are public by default

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

368.

Which of the following statements about constructors and destructors are
true?

Answer

Correct Answer: Constructors can take parameters, but destructors cannot
It is illegal to define a constructor as virtual

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

369.

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?

Answer

Correct Answer: Protected

Note: This Question is unanswered, help us to find answer for this one

370.

Which of the following is not a standard STL header?

Answer

Correct Answer: <array>

Note: This Question is unanswered, help us to find answer for this one

371.

Consider the sample code given below and answer the question that
follows.
template <class T> Run(T process);
Which one of the following is an example of the sample code given above?

Answer

Correct Answer: A template function declaration

Note: This Question is unanswered, help us to find answer for this one

372.

Consider the sample code given below and 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?

Answer

Correct Answer: The code will compile without errors

Note: This Question is unanswered, help us to find answer for this one

373.

Consider the following statements relating to static member functions and
choose the appropriate options:
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

Answer

Correct Answer: Only 1 and 2 are true

Note: This Question is unanswered, help us to find answer for this one

374.

What will be the 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();
}

Answer

Correct Answer: Base Derived

Note: This Question is unanswered, help us to find answer for this one

375.

Consider the line of code given below and answer the question that follows.
class screen;
Which of the following statements are true about the class declaration
above?

Answer

Correct Answer: The syntax is correct

Note: This Question is unanswered, help us to find answer for this one

376.

Which of the following is NOT a standard sorting algorithm:

Answer

Correct Answer: std::qsort

Note: This Question is unanswered, help us to find answer for this one

377.

What does ADT stand for?

Answer

Correct Answer: Abstract data type

Note: This Question is unanswered, help us to find answer for this one

378.

In C++, the keyword auto can be used for:

Answer

Correct Answer: Declaration of a local variable

Note: This Question is unanswered, help us to find answer for this one

379.

In C++, the keyword auto can be used for:

Answer

Correct Answer: vector::erase can be used to delete a single element and a range of elements of the vector
After calling, vector::erase causes some of the iterators referencing the vector to become invalid
vector::size returns the number of elements in the vector

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

380.

Which of the following statements about function overloading, is true?

Answer

Correct Answer: The parameter lists and const keyword are used to distinguish functions of the same name declared in the same scope

Note: This Question is unanswered, help us to find answer for this one

381.

Consider the sample code given below and 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?

Answer

Correct Answer: Person(const Person &p);

Note: This Question is unanswered, help us to find answer for this one

382.

Which of the following statements are true for operator overloading in C++?

Answer

Correct Answer: The * operator can be overloaded to perform division
The * operator can be overloaded to perform assignment
Operators can be overloaded globally

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

383.

What linkage specifier do you use in order to cause your C++ functions to
have C linkage

Answer

Correct Answer: extern "C"

Note: This Question is unanswered, help us to find answer for this one

384.

Which of the following statements regarding functions are false?

Answer

Correct Answer: You can create arrays of functions

Note: This Question is unanswered, help us to find answer for this one

385.

A pure virtual function can be declared by _______.

Answer

Correct Answer: equating it to 0
equating it to NULL

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

386.

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?

Answer

Correct Answer: The code will crash at runtime

Note: This Question is unanswered, help us to find answer for this one

387.

Which of the following is a predefined object in C++ and used to insert to the standard error output?

Answer

Correct Answer: std::ce

Note: This Question is unanswered, help us to find answer for this one

388.

Which of the following are true about class member functions and constructors?

Answer

Correct Answer: A member function can return values but a constructor cannot

Note: This Question is unanswered, help us to find answer for this one

389.

Which of the following sets of functions do not qualify as overloaded functions?

Answer

Correct Answer: void x(int,char) int *x(int,char)

Note: This Question is unanswered, help us to find answer for this one

390.

If a matching catch handler (or ellipsis catch handler) cannot be found for the current exception, then the following predefined runtime function is called ______.

Answer

Correct Answer: terminate

Note: This Question is unanswered, help us to find answer for this one

391.

Consider the following code:

 #include<iostream>
 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?

Answer

Correct Answer: The code will compile and run without errors

Note: This Question is unanswered, help us to find answer for this one

392.

Which of the following operators cannot be overloaded?

Answer

Correct Answer: .
::
?:

Note: This question has more than 1 correct answers

Note: This Question is unanswered, help us to find answer for this one

393.

What will be the output of the following code?

 #include<iostream>
 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();
 }

Answer

Correct Answer: In Base In Base In Derived

Note: This Question is unanswered, help us to find answer for this one

394.

Unary operator overloaded by means of a friend function takes one reference argument.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

395. Which of the following STL classes is deprecated (ie should no longer be used)


Answer

Correct Answer: ostrstream

Note: This Question is unanswered, help us to find answer for this one

396. 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?


Answer

Correct Answer: When an object of MyClass is passed by value to a function

Note: This Question is unanswered, help us to find answer for this one

397. 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?


Answer

Correct Answer: Base Exception

Note: This Question is unanswered, help us to find answer for this one

398. How many arguments can be passed to an overloaded binary operator?


Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

399. Which of the following statements are true?


Answer

Correct Answer: Macro usage should be avoided because they are error prone

Note: This Question is unanswered, help us to find answer for this one

400. Which of the following members and functions can only be accessed from within the class in which it was defined and from within its derived classes?

Answer

Correct Answer: Protected

Note: This Question is unanswered, help us to find answer for this one

401. Which of the following is the difference between these two declarations in C++? void foo(); void foo(void);

Answer

Correct Answer: No difference, they are equivalent

Note: This Question is unanswered, help us to find answer for this one

402. Given the following code, how many bytes of memory does an instance of foo occupy? class foo { int x; short y; };

Answer

Correct Answer: Depends on the target platform and implementation

Note: This Question is unanswered, help us to find answer for this one

403. 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; } };

Answer

Correct Answer: No, friend declarations are not transitive

Note: This Question is unanswered, help us to find answer for this one

404. Which is the initial value of result if the following variable definition is declared inside a function body? int result;

Answer

Correct Answer: undefined

Note: This Question is unanswered, help us to find answer for this one

405. Which of the following is a variable that holds a large group of similar type data?

Answer

Correct Answer: Array

Note: This Question is unanswered, help us to find answer for this one

406. Which task does the following statement perform? std::cout << x;

Answer

Correct Answer: Writes the contents of x to stdout

Note: This Question is unanswered, help us to find answer for this one

407. Which of the following is the content of vector v given the code below? std::vector v(4); std::fill(v.begin(), v.end(), 4);

Answer

Correct Answer: 4, 4, 4, 4

Note: This Question is unanswered, help us to find answer for this one

408. What is the difference between the following? int a(0); and int a = 0;

Answer

Correct Answer: None

Note: This Question is unanswered, help us to find answer for this one

409. Which is the right way to place an opening curly bracket in C++?

Answer

Correct Answer: There is no C++ rule about placing curly brackets

Note: This Question is unanswered, help us to find answer for this one

410. 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;.

Answer

Correct Answer: myItem->units

Note: This Question is unanswered, help us to find answer for this one

411. For which circumstance should you use the preprocessor directive #include <iostream> in your C++ program?

Answer

Correct Answer: Your program uses cout function calls

Note: This Question is unanswered, help us to find answer for this one

412. Which purpose should the following line serve in a C++ program? #include

Answer

Correct Answer: Tells the preprocessor to include the iostream standard file

Note: This Question is unanswered, help us to find answer for this one

413. Which of the following do the ellipses indicate, given the code sample below? catch(…) { cout << "exception";}.

Answer

Correct Answer: The handler will catch any type of error thrown

Note: This Question is unanswered, help us to find answer for this one

414. Given the following code: void foo(){ static int x=10; } When is x created?

Answer

Correct Answer: At the first call of foo()

Note: This Question is unanswered, help us to find answer for this one

415. Which of the following is not permitted in a pure virtual class in C++?

Answer

Correct Answer: All of these are permitted

Note: This Question is unanswered, help us to find answer for this one

416. Given an external function that needs access to private and protected members of a class, you would specify the function as:

Answer

Correct Answer: friend myClass myFunction(myClass);

Note: This Question is unanswered, help us to find answer for this one

417. Which of the following does the code below create? int * p; p=0;?

Answer

Correct Answer: Null pointer

Note: This Question is unanswered, help us to find answer for this one

418. Which is the difference between classes and structures?

Answer

Correct Answer: Elements of a class are private by default

Note: This Question is unanswered, help us to find answer for this one

419. Which of the following does "int *p; p = 0;" do?

Answer

Correct Answer: Sets p to nullptr

Note: This Question is unanswered, help us to find answer for this one

420. 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();

Answer

Correct Answer: B::x()

Note: This Question is unanswered, help us to find answer for this one

421. 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!";

Answer

Correct Answer: aString.substr(6,5);

Note: This Question is unanswered, help us to find answer for this one

422. Which is the value of C in the following code? int C++;

Answer

Correct Answer: This is invalid code in C++

Note: This Question is unanswered, help us to find answer for this one

423. Which is the output of the following program? int main () { cout << "Hello World!"; return 0; }

Answer

Correct Answer: Hello World!

Note: This Question is unanswered, help us to find answer for this one

424. Which statement declares a function with arguments passed by reference?

Answer

Correct Answer: void myfunction(int& a, int& b)

Note: This Question is unanswered, help us to find answer for this one

425. The printmsg function does not require any arguments. Which of the following statements calls the printmsg function?

Answer

Correct Answer: printmsg();

Note: This Question is unanswered, help us to find answer for this one

426. Which statement declares a function with a default value for an argument?

Answer

Correct Answer: void myfunction(int a=2)

Note: This Question is unanswered, help us to find answer for this one

427. The process of TYPECASTING makes one variable appear to be another type of data. Which of the following are the two processes of TYPECASTING?

Answer

Correct Answer: Explicit and Implicit

Note: This Question is unanswered, help us to find answer for this one

428. Which of the following is the default access level assigned to members of a class?

Answer

Correct Answer: Private

Note: This Question is unanswered, help us to find answer for this one

429. How should the main part of the following program access myNamespace variable a, given the code below? namespace myNamespace { int a; int b; }

Answer

Correct Answer: myNamespace::a

Note: This Question is unanswered, help us to find answer for this one

430. Which of the following describes the difference between an array and a vector?

Answer

Correct Answer: Vectors can be dynamically resized, but an array's size is fixed

Note: This Question is unanswered, help us to find answer for this one

431. Which is the correct value of 7 == 5+2 ? 4 : 3?

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

432. Which of the following function prototypes will overload the addition operator between two objects of the type Distance?

Answer

Correct Answer: Distance operator+(Distance a, Distance b);

Note: This Question is unanswered, help us to find answer for this one

433. 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.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

434. Which of the following C++ function declarations is valid and passes the the function parameters by reference?

Answer

Correct Answer: void myFunction (int& a, int& b, int& c)

Note: This Question is unanswered, help us to find answer for this one

435. At which point does a C++ program begin its execution?

Answer

Correct Answer: Main function

Note: This Question is unanswered, help us to find answer for this one

436. Which symbol separates C++ statements?

Answer

Correct Answer: Semi-colon (;)

Note: This Question is unanswered, help us to find answer for this one

437. Which term can describe int, long, double, and string?

Answer

Correct Answer: Data Types

Note: This Question is unanswered, help us to find answer for this one

438. From which programming language was C++ derived?

Answer

Correct Answer: C

Note: This Question is unanswered, help us to find answer for this one

439. Which of the following means the same as the statement below? i += 5;

Answer

Correct Answer: i = i + 5;

Note: This Question is unanswered, help us to find answer for this one

440. Which of the following symbols calls the pre-processor to include the specified system files such as iostream?

Answer

Correct Answer: Hash Symbol (#)

Note: This Question is unanswered, help us to find answer for this one

441. Which is the correct term for two different C++ functions that have the same name but different parameter types?

Answer

Correct Answer: Function overloading

Note: This Question is unanswered, help us to find answer for this one

442. Which of the following is the value of a = 11 % 3;?

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

443. From which of the following is the dynamic memory requested by C++ programs allocated?

Answer

Correct Answer: Memory heap

Note: This Question is unanswered, help us to find answer for this one

444. Which term describes an ordered and indexed sequence of values?

Answer

Correct Answer: Array

Note: This Question is unanswered, help us to find answer for this one

445. char * array = "Hello"; char array[] = "Hello"; What is the difference between the above two, if any, when using sizeof operator?

Answer

Correct Answer: The sizeof of an array gives the number of elements in the array, but sizeof of a pointer gives the actual size of a pointer variable

Note: This Question is unanswered, help us to find answer for this one

446. Which process does operator+ perform on two instances of std::string?

Answer

Correct Answer: String concatenation

Note: This Question is unanswered, help us to find answer for this one

447. Which of the following should you use the given code to do? std::vector foo {5}; (assume C++11)

Answer

Correct Answer: Initialize a vector with 1 element of the value 5

Note: This Question is unanswered, help us to find answer for this one

448. C++ is strongly Object Oriented Language ?

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

449. Which of the following statements about virtual base classes is correct?

Answer

Correct Answer: It is used to avoid multiple copies of base class in derived class.

Note: This Question is unanswered, help us to find answer for this one

450. How can we make a class abstract?

Answer

Correct Answer: By making at least one member function as pure virtual function.

Note: This Question is unanswered, help us to find answer for this one

451. In C++, what will the code below output? #include main() { for (int x=1; x<10; ++x) { ++x; } cout << x; return 0; }

Answer

Correct Answer: "x" was not declared in this scope.

Note: This Question is unanswered, help us to find answer for this one

452. A template class does all of the following EXCEPT

Answer

Correct Answer: Template classes are primarily used as base classes for other derived classes.

Note: This Question is unanswered, help us to find answer for this one

453. An asterisk (*) immediately after a data type declares a variable as a pointer, and...

Answer

Correct Answer: an asterisk (*) immediately before a variable name dereferences a pointer giving you its value when that variable has already been declared.

Note: This Question is unanswered, help us to find answer for this one

454. All of the following are true EXCEPT:

Answer

Correct Answer: Global variables are usually a bad choice as they more often cause memory leaks than locally scoped variables.

Note: This Question is unanswered, help us to find answer for this one

455. True/False. 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.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

456. True/False. There is no difference between a * pointer and an & reference.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

457. True/False. A class declaration requires a semi-colon (;) after it is complete. Ie. Class MyClass { some code here };

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

458. A memory leak occurs when:

Answer

Correct Answer: Memory is allocated and then goes out of scope before it is released.

Note: This Question is unanswered, help us to find answer for this one

459. Identifying classes by their standard typedefs, which of the following is NOT declared by the standard C++ library?

Answer

Correct Answer: istream & istream::operator >> ( streambuf & )

Note: This Question is unanswered, help us to find answer for this one

460. What is the value of (false - ~0)?

Answer

Correct Answer: 1

Note: This Question is unanswered, help us to find answer for this one

461. In C++ the three STL (Standard Template Library) container adapters are:

Answer

Correct Answer: stack, queue, priority_queue

Note: This Question is unanswered, help us to find answer for this one

462. What is the effect of 'const' following a member function's parameter declarations?

Answer

Correct Answer: The function may be called on a const qualified object, and treats the object as const qualified.

Note: This Question is unanswered, help us to find answer for this one

463. Can a static member function be declared as const?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

464. What type of exceptions will the following function throw: int myfunction (int a) throw();?

Answer

Correct Answer: None

Note: This Question is unanswered, help us to find answer for this one

465. What does operator -> () do?

Answer

Correct Answer: Defines the structure dereference operator for a class

Note: This Question is unanswered, help us to find answer for this one

466. What will a declaration such as “extern "C" char foo(int);” do?

Answer

Correct Answer: It ensures that foo's mangled link name matches that of the C compiler so it can be called from C functions.

Note: This Question is unanswered, help us to find answer for this one

467. double a = 1.0; double *p = &a; a = a/*p; Which of the following statements about the code is true?

Answer

Correct Answer: /* means the start of comments.

Note: This Question is unanswered, help us to find answer for this one

468. What is the value of bar(1) in: int foo(int &x) { return ++x; } int bar(int x) { x += foo(x); return x; }

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

469. According to the C++11 standard, which of these is a keyword?

Answer

Correct Answer: char32_t

Note: This Question is unanswered, help us to find answer for this one

470. In the following 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.

Answer

Correct Answer: void my_lock::lock() { int exp(1); while (!data.compare_exchange_strong(exp, 0)) exp = 1; }

Note: This Question is unanswered, help us to find answer for this one

471. What can we say about: myClass::foo(){ delete this; } .. void func(){ myClass *a = new myClass(); a->foo(); }

Answer

Correct Answer: None of these.

Note: This Question is unanswered, help us to find answer for this one

472. Is the following well-formatted C++11 code? %:include int main (void) <% std::vector ivec <% 1, 2, 3 }; ??>

Answer

Correct Answer: Yes, it will compile.

Note: This Question is unanswered, help us to find answer for this one

473. If we have a class myClass , what can we say about the code: myClass::~myClass(){ delete this; this = NULL; }

Answer

Correct Answer: It won't compile

Note: This Question is unanswered, help us to find answer for this one

474. 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?

Answer

Correct Answer: public

Note: This Question is unanswered, help us to find answer for this one

475. 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.

Answer

Correct Answer: false true true

Note: This Question is unanswered, help us to find answer for this one

476. If after: a* var = new a(); var's value is 0x000C45710 What is its value after: delete var;

Answer

Correct Answer: 0x000C45710

Note: This Question is unanswered, help us to find answer for this one

477. If sizeof(int)==4 what is sizeof(long)?

Answer

Correct Answer: At least 4

Note: This Question is unanswered, help us to find answer for this one

478. signed int a = 5; unsigned char b = -5; unsigned int c = a > b; What is the value of c?

Answer

Correct Answer: 0

Note: This Question is unanswered, help us to find answer for this one

479. int* a = {1, 2, 3}; | Where are the 1,2,3 values stored?

Answer

Correct Answer: This code is not valid C++

Note: This Question is unanswered, help us to find answer for this one

480. According to the IEEE standard, which of the following will always evaluate to true if the value of "var" is NaN?

Answer

Correct Answer: var != var

Note: This Question is unanswered, help us to find answer for this one

481. 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?

Answer

Correct Answer: Any one of the specified choices fixes compilation error

Note: This Question is unanswered, help us to find answer for this one

482. Assuming you are using 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; };

Answer

Correct Answer: 12

Note: This Question is unanswered, help us to find answer for this one

483. 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; }

Answer

Correct Answer: Always

Note: This Question is unanswered, help us to find answer for this one

484. std::deque<int> queue; queue.push_back(1); int& ref = queue.back(); queue.push_back(2); Where does ref point to?

Answer

Correct Answer: Front of the queue

Note: This Question is unanswered, help us to find answer for this one

485. What is the 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; }

Answer

Correct Answer: AB

Note: This Question is unanswered, help us to find answer for this one

486. Virtual inheritance is needed...

Answer

Correct Answer: to not get multiple ambiguous copies of members of ancestor classes

Note: This Question is unanswered, help us to find answer for this one

487. What is the value of "v"? auto &p = 10; double v = p;

Answer

Correct Answer: compilation error

Note: This Question is unanswered, help us to find answer for this one

488. 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.

Answer

Correct Answer: In header: extern std::atomic x; In source: std::atomic x(20);

Note: This Question is unanswered, help us to find answer for this one

489. What is the purpose of std::set_union?

Answer

Correct Answer: Constructs a sorted union of the elements from two ranges.

Note: This Question is unanswered, help us to find answer for this one

490. What will be the output? auto fn = [](unsigned char a){ cout << std::hex << (int)a << endl; }; fn(-1);

Answer

Correct Answer: ff

Note: This Question is unanswered, help us to find answer for this one

491. Which of the following is not a member of std::weak_ptr?

Answer

Correct Answer: weak_ptr(T *r) noexcept;

Note: This Question is unanswered, help us to find answer for this one

492. How do you declare a pointer where the memory location being pointed to cannot be altered, but the value being pointed to can?

Answer

Correct Answer: int * const x = &y;

Note: This Question is unanswered, help us to find answer for this one

493. std::function<int()> f; f(); f is not initialized. What exception is thrown, when you try to call it?

Answer

Correct Answer: std::bad_function_call

Note: This Question is unanswered, help us to find answer for this one

494. 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; }

Answer

Correct Answer: shape::move shape::move shape::move

Note: This Question is unanswered, help us to find answer for this one

495. const std::string * s; std::string const * g; What can be said about s and g?

Answer

Correct Answer: both s and g are modifiable pointers to an immutable string

Note: This Question is unanswered, help us to find answer for this one

496. Which of the following operators can you not overload?

Answer

Correct Answer: . (dot)

Note: This Question is unanswered, help us to find answer for this one

497. What will be the output of the following C++ code ? #include class A { int a; public: void foo() {std::cout<<"foo";} }; int main() { A* trial=nullptr; trial->foo(); }

Answer

Correct Answer: foo

Note: This Question is unanswered, help us to find answer for this one

498. What is the 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; }

Answer

Correct Answer: first

Note: This Question is unanswered, help us to find answer for this one

499. The value of "(sizeof(short) == sizeof(int) && sizeof(int) == sizeof(long))" is

Answer

Correct Answer: implementation defined

Note: This Question is unanswered, help us to find answer for this one

500. class A { int x; protected: int y; public: int z; }; class B: public virtual A { }; What is the privacy level of B::x?

Answer

Correct Answer: B does not inherit access to x from A.

Note: This Question is unanswered, help us to find answer for this one

501. 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?

Answer

Correct Answer: 0,8,2,6,4,5,3,7,1,9

Note: This Question is unanswered, help us to find answer for this one

502. Which function always returns an rvalue reference from "x", which can be used to indicate the object is going to be destroyed soon?

Answer

Correct Answer: std::move(x)

Note: This Question is unanswered, help us to find answer for this one

503. std::vector<int> v(10); std::iota(v.begin(), v.end(), 10); What is the content of vector v?

Answer

Correct Answer: 10,11,12,13,14,15,16,17,18,19

Note: This Question is unanswered, help us to find answer for this one

504. What is the output of the following program? int a, b = 3; const int& ar[]= {a, b}; ar[0] = 2; std::cout << ar[0];

Answer

Correct Answer: no output; program is ill-formed

Note: This Question is unanswered, help us to find answer for this one

505. What is value of x, if sizeof(int) == 4? unsigned int a = 0x98765432; unsigned int x = a >> 33;

Answer

Correct Answer: This is undefined behavior

Note: This Question is unanswered, help us to find answer for this one

506. class foo { foo(){}; }; class boo : public foo { boo() : foo() {}; }; which standard allows compilation of this code.

Answer

Correct Answer: none, the code wont compile

Note: This Question is unanswered, help us to find answer for this one

507. Is it possible to create class instance placed at a particular location in memory?

Answer

Correct Answer: Yes, placement new does this.

Note: This Question is unanswered, help us to find answer for this one

508. int a[] {1, 2, 3}; a[[] { return 2; }()] += 2; What is the value of a[2]?

Answer

Correct Answer: Compile error: malformed attribute.

Note: This Question is unanswered, help us to find answer for this one

509. What is the output of the following program? #include #include int main () { std::vector int_values {3}; for (auto const& vv: int_values) { std::cout << vv; } }

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

510. According to the C++ standard, what is sizeof(void)?

Answer

Correct Answer: Nothing, void doesn't have a size.

Note: This Question is unanswered, help us to find answer for this one

511. What is the guaranteed complexity of std::push_heap?

Answer

Correct Answer: O(log(n))

Note: This Question is unanswered, help us to find answer for this one

512. What is the below code? struct code { unsigned int x: 4; unsigned int y: 4; };

Answer

Correct Answer: A bit field structure declaration.

Note: This Question is unanswered, help us to find answer for this one

513. std::tuple person{"John Doe", 42}; std::cout << std::get<1>(person); What is the output?

Answer

Correct Answer: 42

Note: This Question is unanswered, help us to find answer for this one

514. What is the type being defined here: typedef A (B::*C)(D, E) const;

Answer

Correct Answer: C is defined to be a constant member function pointer of class B taking arguments of types D and E, returning type A.

Note: This Question is unanswered, help us to find answer for this one

515. enum { a, b, c = b + 2 }; What is the value of c?

Answer

Correct Answer: 3

Note: This Question is unanswered, help us to find answer for this one

516. Where T is a type: std::vector<T>::at vs std::vector<T>::operator[]:

Answer

Correct Answer: at is always bounds checked. operator[] is not.

Note: This Question is unanswered, help us to find answer for this one

517. Which is NOT a valid hash table provided by the STL?

Answer

Correct Answer: hash_table

Note: This Question is unanswered, help us to find answer for this one

518. 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; }

Answer

Correct Answer: Yes.

Note: This Question is unanswered, help us to find answer for this one

519. What is the output of the following code? int a=8; for(int i=1; i<=i*3; i++) n++;

Answer

Correct Answer: Infinite loop.

Note: This Question is unanswered, help us to find answer for this one

520. Given: union a { int x; short y; }; a var[20]; How many bytes of memory does var occupy?

Answer

Correct Answer: Depends

Note: This Question is unanswered, help us to find answer for this one

521. What is a key difference between a struct and union in terms of memory size?

Answer

Correct Answer: A union is the size of its largest data member whereas the size of a struct is at least the sum of the size of the struct data members

Note: This Question is unanswered, help us to find answer for this one

522. If you do not supply any constructors for your class, which constructor(s) will be created by the compiler?

Answer

Correct Answer: Both of these

Note: This Question is unanswered, help us to find answer for this one

523. class A { int x; protected: int y; public: int z; }; class B: private A { }; What is the privacy level of B::z?

Answer

Correct Answer: private

Note: This Question is unanswered, help us to find answer for this one

524. What is the value of 10.10 % 3?

Answer

Correct Answer: None, that is an invalid mix of types.

Note: This Question is unanswered, help us to find answer for this one

525. What is the value of x after the following code: int x = 0; if (x = 1) { x = 2; } else { x = 1; }

Answer

Correct Answer: 2

Note: This Question is unanswered, help us to find answer for this one

526. Which one is theorically faster ?

Answer

Correct Answer: ++i

Note: This Question is unanswered, help us to find answer for this one

527. What type of exceptions can the following function throw: int myfunction (int a);?

Answer

Correct Answer: All

Note: This Question is unanswered, help us to find answer for this one

528. Which of the following is a potential side-effect of inlining functions?

Answer

Correct Answer: The size of the compiled binary increases

Note: This Question is unanswered, help us to find answer for this one

529. String literals can extend to more than a single line of code by putting which character at the end of each unfinished line?

Answer

Correct Answer: a backslash (\)

Note: This Question is unanswered, help us to find answer for this one

530. How would you access "blue" in the "color" enum class? enum class color { red, blue, green };

Answer

Correct Answer: color::blue

Note: This Question is unanswered, help us to find answer for this one

531. What is the data range for an unsigned integer value in C++ on a system where ints are 32 bits?

Answer

Correct Answer: 0 to 4,294,967,295

Note: This Question is unanswered, help us to find answer for this one

532. Is the following legal C++ code? | char *str = "abc" + "def";

Answer

Correct Answer: No.

Note: This Question is unanswered, help us to find answer for this one

533. An anonymous namespace is used to...

Answer

Correct Answer: prevent external access to declarations local to a compilation unit

Note: This Question is unanswered, help us to find answer for this one

534. Which of the following calls method foo() from the parent class Parent of the current class?

Answer

Correct Answer: Parent::foo();

Note: This Question is unanswered, help us to find answer for this one

535. A void pointer is a special type of pointer which indicates the...

Answer

Correct Answer: absence of a type for the pointer.

Note: This Question is unanswered, help us to find answer for this one

536. Which of the following statements uses a Lambda expression?

Answer

Correct Answer: bool is_odd = [](int n) {return n%2==1;};

Note: This Question is unanswered, help us to find answer for this one

537. Which operator cannot be overloaded by a class member function?

Answer

Correct Answer: ?

Note: This Question is unanswered, help us to find answer for this one

538. Suppose int * a = new int[3]; How would you deallocate the memory block pointed by a?

Answer

Correct Answer: delete[] a;

Note: This Question is unanswered, help us to find answer for this one

539. What is the time complexity of delete the first variable in a deque object (e.g., deque<int> a;)?

Answer

Correct Answer: O(1)

Note: This Question is unanswered, help us to find answer for this one

540. What is a virtual function in C++?

Answer

Correct Answer: A class member function that you expect to be redefined in derived classes.

Note: This Question is unanswered, help us to find answer for this one

541. What does the "explicit" keyword do?

Answer

Correct Answer: It prevents a single-argument constructor from being used in an implicit conversion

Note: This Question is unanswered, help us to find answer for this one

542. int *array = new int[10]; delete array;

Answer

Correct Answer: This code has undefined behavior

Note: This Question is unanswered, help us to find answer for this one

543. Which C++ keyword allows the compiler to determine the type of a variable by the value used to initialized it?

Answer

Correct Answer: auto

Note: This Question is unanswered, help us to find answer for this one

544. Thinking about data members and addressable memory, how are a struct, class and union different?

Answer

Correct Answer: Struct and class data members are allocated in memory sequentially whereas a union is allocated enough memory for the largest data member only

Note: This Question is unanswered, help us to find answer for this one

545. What is the data type for the following: L"Hello World"?

Answer

Correct Answer: a wide character string

Note: This Question is unanswered, help us to find answer for this one

546. Which class(es) can be used to perform both input and output on files in C++?

Answer

Correct Answer: fstream

Note: This Question is unanswered, help us to find answer for this one

547. Which of the following rules apply to operator overloading in C++?

Answer

Correct Answer: Both of the other answers are correct.

Note: This Question is unanswered, help us to find answer for this one

548. In C++, what is the difference between these two declarations: void foo(); void foo(void);

Answer

Correct Answer: None, they are equivalent.

Note: This Question is unanswered, help us to find answer for this one

549. What is the size of the character array which would hold the value "Helloo"?

Answer

Correct Answer: 7

Note: This Question is unanswered, help us to find answer for this one

550. Which of these is a difference between struct and class types?

Answer

Correct Answer: Structs have public privacy by default, classes use private.

Note: This Question is unanswered, help us to find answer for this one

551. Define a way other than using the keyword inline to make a function inline

Answer

Correct Answer: The function must be defined inside the class.

Note: This Question is unanswered, help us to find answer for this one

552. True or False: A class that has a pure virtual method can be instantiated.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

553. What is the value of 2--2?

Answer

Correct Answer: Nothing, that is not a valid C++ expression.

Note: This Question is unanswered, help us to find answer for this one

554. Where does the compiler first look for file.h in the following directive: #include "file.h" ?

Answer

Correct Answer: The same directory that includes the file containing the directive.

Note: This Question is unanswered, help us to find answer for this one

555. std::vector<int> foo(5);

Answer

Correct Answer: Initializes a vector with 5 elements of value 0.

Note: This Question is unanswered, help us to find answer for this one

556. Within a class declaration, the statement "virtual int foo() = 0;" does what?

Answer

Correct Answer: Declares a pure virtual function.

Note: This Question is unanswered, help us to find answer for this one

557. Given this code, what is the output? #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; }

Answer

Correct Answer: shape::move circle::move rectangle::move

Note: This Question is unanswered, help us to find answer for this one

558. What does the line: #include <iostream> mean in a C++ program?

Answer

Correct Answer: It tells the preprocessor to include the iostream standard file.

Note: This Question is unanswered, help us to find answer for this one

559. Which of the following is a valid variable identifier in C++?

Answer

Correct Answer: m_test

Note: This Question is unanswered, help us to find answer for this one

560. Defined data types (typedef) allow you to create...

Answer

Correct Answer: alternate names for existing types in C++.

Note: This Question is unanswered, help us to find answer for this one

561. 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?

Answer

Correct Answer: myItem->units

Note: This Question is unanswered, help us to find answer for this one

562. Which of the following is not a specific type casting operator in the C++ language?

Answer

Correct Answer: unknown_cast

Note: This Question is unanswered, help us to find answer for this one

563. Consider this code fragment: a = 25; b = &a; What does b equal?

Answer

Correct Answer: address of a

Note: This Question is unanswered, help us to find answer for this one

564. Which of the following can cause a memory corruption error?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

565. What will 'int a = 'a';' do?

Answer

Correct Answer: It will declare a new variable a and set it to 97 (assuming a machine that uses ASCII).

Note: This Question is unanswered, help us to find answer for this one

566. std::vector<int> v(4); std::fill(v.begin(), v.end(), 4); What is the content of vector v?

Answer

Correct Answer: 4,4,4,4

Note: This Question is unanswered, help us to find answer for this one

567. True or False: In C++, a comment can only be specified with a leading //.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

568. What is the difference between a class and a struct

Answer

Correct Answer: The members of a class are private by default, and the members of a struct are public by default.

Note: This Question is unanswered, help us to find answer for this one

569. What does the sizeof(arg) operator do?

Answer

Correct Answer: returns the size in bytes of arg

Note: This Question is unanswered, help us to find answer for this one

570. Classes can contain static member variables which are global to the class and...

Answer

Correct Answer: can be accessed by all objects of the same class.

Note: This Question is unanswered, help us to find answer for this one

571. Which is(are) an example(s) of valid C++ function prototype(s)?

Answer

Correct Answer: all of these

Note: This Question is unanswered, help us to find answer for this one

572. What is an advantage to using C++ Templates?

Answer

Correct Answer: all of these

Note: This Question is unanswered, help us to find answer for this one

573. Can constructors be overloaded?

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

574. The printmsg function does not require any arguments. Choose the statement which calls the function.

Answer

Correct Answer: printmsg();

Note: This Question is unanswered, help us to find answer for this one

575. In the following line of C++ code, int foo[50]; what does the number 50 represent?

Answer

Correct Answer: The number of integer elements the array shall hold.

Note: This Question is unanswered, help us to find answer for this one

576. What is the value of i after the following statement(s)? int i (4.36);

Answer

Correct Answer: 4

Note: This Question is unanswered, help us to find answer for this one

577. In C++, a single line comment needs to be begun with

Answer

Correct Answer: a leading //.

Note: This Question is unanswered, help us to find answer for this one

578. What does the following statement mean? const int a = 50;

Answer

Correct Answer: The value of a cannot change from 50.

Note: This Question is unanswered, help us to find answer for this one

579. A void pointer is a special type of pointer which indicates the absence of a type for the pointer.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

580. Which is a valid comment statement in C++?

Answer

Correct Answer: Both of these

Note: This Question is unanswered, help us to find answer for this one

581. Which statement assigns to variable a the address of variable b?

Answer

Correct Answer: a = &b;

Note: This Question is unanswered, help us to find answer for this one

582. Which of the following is a reserved word in C++?

Answer

Correct Answer: char

Note: This Question is unanswered, help us to find answer for this one

583. Choose the function declaration which you would use if you did not need to return any value.

Answer

Correct Answer: void myfunction()

Note: This Question is unanswered, help us to find answer for this one

584. 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."?

Answer

Correct Answer: if( (sum == 10) && (total < 20) )printf(

Note: This Question is unanswered, help us to find answer for this one

585. Which of the following is not a C++ primitive type?

Answer

Correct Answer: real

Note: This Question is unanswered, help us to find answer for this one

586. Which of the following operators below allow you to define the member functions of a class outside the class?

Answer

Correct Answer: ::

Note: This Question is unanswered, help us to find answer for this one

587. Which of the following is not a fundamental data type in C++?

Answer

Correct Answer: wide

Note: This Question is unanswered, help us to find answer for this one

588. Which of the following is not a loop structure?

Answer

Correct Answer: stop when loop

Note: This Question is unanswered, help us to find answer for this one

589. How do you declare an integer variable x in C++?

Answer

Correct Answer: int x;

Note: This Question is unanswered, help us to find answer for this one

590. Which of the following is a valid C++ function declaration which does not return a value?

Answer

Correct Answer: void myFunction( int a, int b)

Note: This Question is unanswered, help us to find answer for this one

591. C++ statements are separated by this symbol:

Answer

Correct Answer: Semi-colon (;)

Note: This Question is unanswered, help us to find answer for this one

592. Which of the following is a valid variable declaration statement?

Answer

Correct Answer: int a, b, c;

Note: This Question is unanswered, help us to find answer for this one

593. If you have two different C++ functions which have the same name but different parameter types, it is called...

Answer

Correct Answer: function overloading.

Note: This Question is unanswered, help us to find answer for this one

594. std::make_heap() converts a range into a heap and std::sort_heap() turns a heap into a sorted sequence.

Answer

Correct Answer: true

Note: This Question is unanswered, help us to find answer for this one

595. struct A { int n; }; A a; What is the visibility of a.n?

Answer

Correct Answer: public

Note: This Question is unanswered, help us to find answer for this one

596. 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; }

Answer

Correct Answer: It's depend of double implementation, usually not exactly zero.

Note: This Question is unanswered, help us to find answer for this one

597. What does OOD stand for?

Answer

Correct Answer: Object-Oriented Design

Note: This Question is unanswered, help us to find answer for this one

search
C++ Subjects