Exercise: Constructors And Destructors
Questions for: Constructors And Destructors
What will be the output of the following program?
#include<iostream.h>
int val = 0;
class ExamAdept
{
public:
ExamAdept()
{
cout<< ++val;
}
~ExamAdept()
{
cout<< val--;
}
};
int main()
{
ExamAdept objBix1, objBix2, objBix3;
{
ExamAdept objBix4;
}
return 0;
}
A:
1234
B:
4321
C:
12344321
D:
12341234
Answer: C
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class Bix
{
int x;
public:
Bix();
void Show() const;
~Bix(){}
};
Bix::Bix()
{
x = 5;
}
void Bix::Show() const
{
cout<< x;
}
int main()
{
Bix objB;
objB.Show();
return 0;
}
A:
The program will print the output 5.
B:
The program will print the output Garbage-value.
C:
The program will report compile time error.
D:
The program will report runtime error.
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class Bix
{
int x;
public:
Bix();
~Bix();
void Show() const;
};
Bix::Bix()
{
x = 25;
}
void Bix::Show() const
{
cout<< x;
}
int main()
{
Bix objB;
objB.Show();
return 0;
}
A:
The program will print the output 25.
B:
The program will print the output Garbage-value.
C:
The program will report compile time error.
D:
The program will report runtime error.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class ExamAdept
{
public:
ExamAdept()
{
cout<< "India";
}
~ExamAdept()
{
cout<< "Bix";
}
};
int main()
{
ExamAdept objBix;
return 0;
}
A:
The program will print the output India.
B:
The program will print the output Bix.
C:
The program will print the output ExamAdept.
D:
The program will report compile time error.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
What will be the output of the following program?
#include<iostream.h>
class ExamAdept
{
int x;
public:
ExamAdept(int xx, float yy)
{
cout<< char(yy);
}
};
int main()
{
ExamAdept *p = new ExamAdept(35, 99.50f);
return 0;
}
A:
99
B:
ASCII value of 99
C:
Garbage value
D:
99.50
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.