C++ Programming - Objects and Classes
Exercise : Objects and Classes - Programs
- Objects and Classes - General Questions
- Objects and Classes - Programs
6.
What will be the output of the following program?
#include<iostream.h>
class India
{
public:
struct Bix
{
int x;
float y;
void Function(void)
{
y = x = (x = 4*4);
y = --y * y;
}
void Display()
{
cout<< y << endl;
}
}B;
}I;
int main()
{
I.B.Display();
return 0;
}
7.
What will be the output of the following program?
#include<iostream.h>
#include<string.h>
class IndiaBix
{
int val;
public:
void SetValue(char *str1, char *str2)
{
val = strcspn(str1, str2);
}
void ShowValue()
{
cout<< val;
}
};
int main()
{
IndiaBix objBix;
objBix.SetValue((char*)"India", (char*)"Bix");
objBix.ShowValue();
return 0;
}
8.
Which of the following statement is correct about the program given below?
#include<iostream.h>
#include<string.h>
class IndiaBix
{
public:
void GetData(char *s, int x, int y )
{
int i = 0;
for (i = x-1; y>0; i++)
{
cout<< s[i];
y--;
}
}
};
int main()
{
IndiaBix objBix;
objBix.GetData((char*)"Welcome!", 1, 3);
return 0;
}
9.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class BixData
{
int x, y, z;
public:
BixData(int xx, int yy, int zz)
{
x = ++xx;
y = ++yy;
z = ++zz;
}
void Show()
{
cout<< "" << x++ << " " << y++ << " " << z++;
}
};
int main()
{
BixData objData(1, 2, 3);
objData.Show();
return 0;
}
10.
Which of the following statement is correct about the program given below?
#include<iostream.h>
class IndiaBix
{
int x;
float y;
public:
void Function()
{
x = 4;
y = 2.50; delete this;
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
IndiaBix *pBix = new IndiaBix();
pBix->Function();
pBix->Function();
pBix->Display();
return 0;
}
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers