C++ Programming - Constructors and Destructors
Exercise : Constructors and Destructors - Programs
- Constructors and Destructors - General Questions
- Constructors and Destructors - Programs
1.
What will be the output of the following program?
#include<iostream.h>
class IndiaBix
{
int x;
public:
IndiaBix(int xx, float yy)
{
cout<< char(yy);
}
};
int main()
{
IndiaBix *p = new IndiaBix(35, 99.50f);
return 0;
}
2.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
public:
IndiaBix()
{
cout<< "India";
}
~IndiaBix()
{
cout<< "Bix";
}
};
int main()
{
IndiaBix objBix;
return 0;
}
3.
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;
}
4.
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;
}
5.
What will be the output of the following program?
#include<iostream.h>
int val = 0;
class IndiaBix
{
public:
IndiaBix()
{
cout<< ++val;
}
~IndiaBix()
{
cout<< val--;
}
};
int main()
{
IndiaBix objBix1, objBix2, objBix3;
{
IndiaBix objBix4;
}
return 0;
}
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers