Exercise

1.What is the output of this program?
Note:Includes all required header files

class find
{
int x;
public:
find(int xx, float yy)
{
cout<< char(yy);
}
};
int main()
{
find *p = new find(35, 99.50f);
return 0;
}

A. 99
B. ASCII value of 99
C. Garbage value
D. 99.50

View Answer


2.What is the output of this program?
Note:Includes all required header files

class find
{
public:
find()
{
cout<< "find";
}
~find()
{
cout<< "course";
}
};
int main()
{
find obj;
return 0;
}

A. The program will print the output find.
B. The program will print the output course.
C. The program will print the output findcourse.
D. The program will report compile time error.

View Answer


3.What is the output of this program?
Note:Includes all required header files

class find
{
int x;
public:
find();
~find();
void Show() const;
};
find::find()
{
x = 50;
}
void find::Show() const
{
cout<< x;
}
int main()
{
find obj;
obj.Show();
return 0;
}

A. The program will print the output 50.
B. The program will print the output Garbage-value.
C. The program will report compile time error.
D. The program will report runtime error.

View Answer


4.Which of the following statement is correct about the program given below?
Note:Includes all required header files

class find
{
int *p;
public:
find(int xx, char ch)
{
p = new int();
*p = xx + int(ch);
cout<< *p;
}
~find()
{
delete p;
}
};
int main()
{
find obj(15, 'A');
return 0;
}

A. The program will print the output 80.
B. The program will print the output 112.
C. The program will print the output garbage value.
D. The program will report compile time error.

View Answer


5.Which of the following is true about the following program
Note:Includes all required header files

class find
{
int x;
public:
find(short ss)
{
cout<< "Short" << endl;
}
find(int xx)
{
cout<< "Int" << endl;
}
find(float ff)
{
cout<< "Float" << endl;
}
~find()
{
cout<< "Final";
}
};
int main()
{
find *ptr = new find('F');
return 0;
}

A. The program will print the output Short .
B. The program will print the output Final .
C. The program will print the output Float .
D. The program will print the output Int.

View Answer


6.What will be the output of this program?
Note:Includes all required header files

using namespace std;
class find
{
private:
int x,y;
public:
void find(int a,int b)
{ x=a; y=b;}
};
int main()
{
find s;
return 0;
}

A. Compile Time Error
B. Run Time Error
C. No Error
D. Warning

View Answer


7.What will be the output of this program?
Note:Includes all required header files

using namespace std;
class sample
{
private:
int x;
public:
void sample(){x=0; printf("Object created.");}
void sample(int a){x=a;}
};
int main()
{
sample s;
return 0;
}

A. Compile Time Error
B. Object Created.
C. Run Time Error
D. Can’t be predicted

View Answer


8. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
int i;
class find
{
public:
~find()
{
i=10;
}
};
int foo()
{
i=3;
find ob;
return i;
}
int main()
{
cout << foo() << endl;
return 0;
}

A. 0
B. 10
C. 3
D. None of the above

View Answer


9. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
class find
{
int id;
static int count;
public:
find() {
count++;
id = count;
cout << "constructor for id " << id << endl;
}
~find() {
cout << "destructor for id " << id << endl;
}
};
int find::count = 0;
int main() {
find 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
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
    destructor for id 1

View Answer


10. What will be the output of the following program?
Note:Includes all required header files

using namespace std;
class find {
find() { cout << "Constructor called"; }
};
int main()
{
find t1;
return 0;
}

A. Compiler Error
B. Runtime Error
C. Constructor called
D. None of the above

View Answer



Discussion

* You must be logged in to add comment.