You are on page 1of 3

Q.1 What will be the output of the following program?

#include <iostream>
using namespace std;
class Program{
int id;
static int count;
public:
Program() {
count++;
id = count;
cout << "constructor for id " << id << endl;
}
~Program() {
cout << "destructor for id " << id << endl;
}
};
int Program::count = 0; //Global Definition
int main() {
Program a[3];
return 0;
}
A. constructor for id 1 constructor for id 2 constructor for id 3 destructor for id
3 destructor for id 2 destructor for id 1
B. constructor for id 1 constructor for id 2 constructor for id 3 destructor for id
1 destructor for id 2 destructor for id 3
C. Compiler Dependent
D. constructor for id 1
Correct Answer : A

Q.2 What will be the output of the following program?


#include <iostream>
using namespace std;
class Program{
static int x;
public:
static void Set(int xx){
x = xx;
}
void Display() {
cout<< x ;
}
};
int Program::x = 0;
int main()
{
Program::Set(33);
Program::Display();
return 0;
}
A. The program will print the output 0.
B. The program will print the output 33.
C. The program will print the output Garbage.
D. The program will report compile time error.
Correct Answer : D

Q.3 Which of the following statements are true about Catch handler?
i) It must be placed immediately after try block T.
ii) It can have multiple parameters.
iii) There must be only one catch handler for every try block.
iv) There can be multiple catch handler for a try block T.
v) Generic catch handler can be placed anywhere after try block.

A. Only i, iv, v
B. Only i, ii, iii
C. Only i, iv
D. Only i, ii
Correct Answer : C

Q.4 How many objects reference can refer during its lifetime?
A. 1
B. 2
C. 3
D. 4
Correct Answer : A

Q.5 What is the output of following code


#include<iostream>
using namespace std;
void print( int x ){
cout<<"int : "<<x<<endl;
}
void print( int &x ){
cout<<"int& : "<<x<<endl;
}
int main( void ){
print( 10 );
return 0;
}
A. int : 10
B. int& : 10
C. Ambiguity error
D. Redefinition error
Correct Answer : A

Q.6 What is the output of following code


int num1 = 10;
namesapce A{
int num1 = 20;
}
int main( void ){
int num1 = 30;
using namespace A;
cout<<"num1 : "<<num1<<endl;
return 0;
}
A. 10
B. 20
C. 30
D. Compiler error
Correct Answer : C

Q.7 Choose incorrect statement about template


A. Using template we can reduce code size.
B. Using template we can not reduce code size.
C. Using template we can not reduce time required to execute code.
D. Using template we can reduce developers efforts.
Correct Answer : A
Q.8 Select correct Statement about inline function.
A. We can declare main function inline.
B. We cand declare constructor inline but we can not declare destructor inline.
C. It is possible to divide inline function code in multiple files.
D. In case of loop, recursion or jump statements, we can not declare function
inline.
Correct Answer : D

Q.9 Manipulator is _________ which is used to format the output.


A. Function
B. Operator
C. Object
D. Keyword
Correct Answer : A

Q.10 Which of the following operator is not allowed to overload using non member
function.
A. =
B. [ ]
C. < >
D. ( )
Correct Answer : C

You might also like