C++ Programming MCQ - Constructor And Destructor

9.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


10.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


11.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


12.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


13.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


14.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


15.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


16. 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






Also check :


Discussion


* You must be logged in to add comment.