Exit Exam CPP - 2
Exit Exam CPP - 2
1. In which steps of problem solving life cycle what input data are needed to solve problem,
what procedure is needed to achieve the result and what output are expected are identified
A. Analysis (problem specification)
B. Algorithm design.
C. Implementation or coding
D. Maintenance and documentation
2. Finiteness property of an Algorithm is
A. The number of steps in the algorithm should be finite.
B. The algorithm should terminate after a finite no. of times.
C. For all possible combinations of input data, the algorithm terminates after a finite
no. of steps
D. A and C
3. Which of the following approach is used by C++?
A. Left-right C. Right-left
B. Bottom-up D. Top-down
4. Which of the following correctly declares an array in C++?
A. array{10}; C. array array[10];
B. int array; D. int array[10];
5. Which concept allows you to reuse the written code in C++?
A. Inheritance C. Abstraction
B. Polymorphism D. Encapsulation
6. To which of the following access specifiers are applicable?
A. Member data C. Both Member data & Functions
B. Functions D. Protected members
7. Which of the following refers to characteristics of an array?
A. Index of an array
B. Elements of the Array
C. Functions of the Array
D. All of the above
10. Which of the following statements supports that reusable code should be one of the
desirable features of any language?
11. Which of the following concept refers to adding new components to the program at the
run time?
A. Dynamic Loading
B. Dynamic binding
C. Data hiding
D. Both A & B
13. Which one of the following correctly refers to the command line arguments?
15. Which one of the following given statements is correct about the increment operator?
16. Which one of the following statements about the pre-increment is true?
18. In C++, which of the following has the associatively of left to right?
A. Addressof
B. Unary operator
C. Logical not
D. Array element access
19. Which of the following can be considered as the correct syntax of for loop?
21. Which of the following methods can be considered the correct and efficient way of
handling arguments with spaces?
A. _something
B. aVariable
C. float2string
D. 2manyLetters
E. X
a. Compile time
b. Run time
c. Is not an error
d. None
34. How many times is the phrase ″In the loop″ printed when the following code is executed?
int i, j=25;
for(i=0; i<j; i++, j--)
{
if(i%2==0)
continue;
cout << ″In the loop″ << endl;
}
a. 6 b. 10 c. 4 d. 5 e. 2
35. What are the three basic control structures used in programming?
a. int, double, string
b. while, do..while, for
c. sequence, decision, repetition
d. input, output, and calculation
36. A loop exit condition must
a. be the last instruction in the body of the loop
b. evaluate to true or false
c. be the first instruction in the body of the loop
d. not use compound conditions
37. A variable which is declared inside the function can be called?
a. Local variable
b. Global variable
c. Normal variable
d. Variable scope
38. If the logic of your program at some point requires you to do one thing or another, which
instruction would you use to implement this decision?
a. while
b. for
c. if..else
d. sequence
e. cin
39. Consider the following code fragment carefully, then answer the question: how many
times will the cout statement execute:
a. 5 times
b. 4 times
c. 6 times
d. 0 times
e. 1 time
40. Find the output of the following code:
int main() {
int x = 10;
cout << -- x + 1<<",";
cout<< x++; }
a. 10, 9
b. 10, 10
c. 9, 10
d. 9, 9
e.
41. Tasks performed by the OS include:
a. Management of secondary storage devices.
b. Memory management
c. Allocation of CPU time
d. All
42. which is not a part of every C++ function.
a. Function header
b. Function body
c. Function selector
d. Function parameters
e. All expect c
43. which one is different from others?
a. int a ;
b. float b;
c. double d;
d. int c = 40;
44. How many times will the print statement be executed?
main(){
int i = 0;
label:
cout << “Interviewbit;
i++;
if(i < 3){
goto label;
}
}
a. times
b. times
c. times
d. error
45. What is the output of the following c++ source code.
a. 65
b. 50
c. 65, 50, 86
d. It is an invalid statement.
47. How many times is the phrase ″In the loop″ printed when the following code is executed?
int a = 4, b = 12;
do{
cout << ″in the loop″<< endl;
a+=2;
b-=2;
} while(a<b);
A. 1 B. 2 C. 3 D. 4 E. 5
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[])
{
char s1[6] = "Hello";
char s2[6] = "World";
char s3[12] = s1 + " " + s2;
cout<<s3;
return 0;
}
a) Hello
b) World
c) Error
d) Hello World
int main()
{
register int i = 1;
int *ptr = &i;
cout << *ptr;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
char c = 74;
cout << c;
return 0;
}
a) I
b) J
c) A
d) N
57. What is the output of the following statements?
int k = 2, g = 20;
k *= g++;
cout << k << “ , ” << g;
a) 42 , 21
b) 40 , 21
c) 40 , 20
d) 2 , 40
58. What is the following statement?
#include <iostream>
using namespace std;
int main ()
{
int a, b, c;
a = 2;
b = 7;
c = (a > b) ? a : b;
cout << c;
return 0;
}
a) 12
b) 14
c) 6
d) 7
65.
66. Which of the following is not correct about structures?
A. It is a programmer defined data types.
B. Structures can contain variables of different data types.
C. Members of structure are accessed through structure variable.
D. The default way of passing structure variable is by reference.
67. Which of the following pairs are incorrectly paired?
a. (cin, read from key board)
b. (cout, write to screen)
c. (ofstream, read from a file)
d. (fstream, write to a file)
68. A constructor is executed when a class is declared.
a. True
b. False
69. Which of the following access modifier is used in a constructor definition by default?
a. Protected
b. Public
c. Private
d. Either A or C
70. Which one of the following statements is true?
a. An ifstream object can create a file.
b. An ofstream object cannot create a file.
c. An ofstream object is used to write a file.
d. A and B
87. Which of the following features of object oriented programming plays an important role
in allowing objects having different internal structures to share the same external
interfaces.
A. objects
B. classes
C. plymorphism
D. message passing
88. What is the effect of using small inline functions on the number of cache misses?
class Example{
Example(){a=b=c=1;}
//Constructor 1
//Constructor 2
//Constructor 3
//Constructor 4
In the above example of constructor overloading, the following statement will call
which constructor
A. Constructor 2
B. Constructor 4
C. Constrcutor 1
D. Type mismatch error
91. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
int main() {
str[found] = '*';
return 0;
}
a. Steve
b. Jobs
c. St*v* j*bs
d. St*v*
i. Output of this program will be ____?
#include
using namespace std;
int main()
{
int a = 5, b = 10, c = 15;
int arr[3] = {&a, &b, &c};
cout << *arr[*arr[1] – 8];
return 0;
}
A. 18
B. 15
C. garbage value
D. compile time error
93. What happens when both of the following C++ programs are compiled and executed?
int main()
{
array<int,5> arr1;
arr1.fill(5);
cout<<get<5>(arr1);
return 0;
}
=====================
===== Program 2 =====
#include <iostream>
#include <array>
int main()
{
array<int,5> arr1;
arr1.fill(5);
cout<<arr1.at(5);
return 0;
}
=====================
a. Program 1 gives compile-time error and Program 2 gives run-time error
b. Program 1 gives run-time error and Program 2 gives compile-time error
c. Both programs results into compile-time error
d. Both programs results into run-time error
i. Derived class do not inherit or overload constructors or destructors from their base
classes.
ii. Destructors can be declared with the keyword virtual
iii. Constructors can be declared with the keyword virtual
95. Which option gives the correct interpretation of the following declaration in C++?
int (*x[10])();
main(){
int i={1,2,3};
cout<<i<<endl;
a. 1
b. 123
c. 3
d. Error
98. What does the following code fragment print?
int[] a = { 1, 2, 3 };
int[] b = { 1, 2, 3 };
System.out.println(a == b);
A. It prints true
B. It prints false.
C. Compile time error
D. None
99. Which from the following is not a correct way to pass a pointer to a function?