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 BixBase
{
int x, y;
public:
BixBase(int xx = 10, int yy = 10)
{
x = xx;
y = yy;
}
void Show()
{
cout<< x * y << endl;
}
};
class BixDerived
{
private:
BixBase objBase;
public:
BixDerived(int xx, int yy) : objBase(xx, yy)
{
objBase.Show();
}
};
int main()
{
BixDerived objDev(10, 20);
return 0;
}
A:
The program will print the output 100.
B:
The program will print the output 200.
C:
The program will print the output Garbage-value.
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<process.h>
class ExamAdept
{
static int x;
public:
ExamAdept()
{
if(x == 1)
exit(0);
else
x++;
}
void Display()
{
cout<< x << " ";
}
};
int ExamAdept::x = 0;
int main()
{
ExamAdept objBix1;
objBix1.Display();
ExamAdept objBix2;
objBix2.Display();
return 0;
}
A:
The program will print the output 1 2.
B:
The program will print the output 0 1.
C:
The program will print the output 1 1.
D:
The program will print the output 1.
Answer: D
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 BixBase
{
public:
float x;
};
class BixDerived : public BixBase
{
public:
char ch;
void Process()
{
ch = (int)((x=12.0)/3.0);
}
void Display()
{
cout<< (int)ch;
}
};
int main()
{
class BixDerived *objDev = new BixDerived;
objDev->Process();
objDev->Display();
return 0;
}
A:
The program will print the output 4.
B:
The program will print the ASCII value of 4.
C:
The program will print the output 0.
D:
The program will print the output garbage.
Answer: A
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
{
static int count;
public:
static void First(void)
{
count = 10;
}
static void Second(int x)
{
count = count + x;
}
static void Display(void)
{
cout<< count << endl;
}
};
int ExamAdept::count = 0;
int main()
{
ExamAdept :: First();
ExamAdept :: Second(5);
ExamAdept :: Display();
return 0;
}
A:
0
B:
5
C:
10
D:
15
Answer: D
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
{
int x;
float y;
public:
void Function()
{
x = 4;
y = 2.50; delete this;
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
ExamAdept *pBix = new ExamAdept();
pBix->Function();
pBix->Function();
pBix->Display();
return 0;
}
A:
The program will print the output 4 2.5.
B:
The program will print the output 4.
C:
The program will report runtime error.
D:
The program will report compile time error.
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.