Exercise: Objects And Classes
Questions for: Objects And Classes
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;
}
A:
The program will print the output 1 2 3.
B:
The program will print the output 2 3 4 .
C:
The program will print the output 4 5 6.
D:
The program will report compile time error.
Answer: B
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h>
#include<string.h>
class ExamAdept
{
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()
{
ExamAdept objBix;
objBix.GetData((char*)"Welcome!", 1, 3);
return 0;
}
A:
The program will print the output me!.
B:
The program will print the output Wel.
C:
The program will print the output !em.
D:
The program will print the output Welcome!.
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
What will be the output of the following program?
#include<iostream.h>
#include<string.h>
class ExamAdept
{
int val;
public:
void SetValue(char *str1, char *str2)
{
val = strcspn(str1, str2);
}
void ShowValue()
{
cout<< val;
}
};
int main()
{
ExamAdept objBix;
objBix.SetValue((char*)"India", (char*)"Bix");
objBix.ShowValue();
return 0;
}
A:
2
B:
3
C:
5
D:
8
Answer: B
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 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;
}
A:
0
B:
1
C:
-1
D:
Garbage value
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 ExamAdept
{
static int x;
public:
static void SetData(int xx)
{
this->x = xx;
}
static void Display()
{
cout<< x ;
}
};
int ExamAdept::x = 0;
int main()
{
ExamAdept::SetData(22);
ExamAdept::Display();
return 0;
}
A:
The program will print the output 0.
B:
The program will print the output 22.
C:
The program will print the output Garbage.
D:
The program will report compile time error.
Answer: D
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.