Cpp Programming 88 – Which of the following access specifier is used as a default in a class definition?
[B]. public[C]. private
[D]. friend
Answer: Option C
Answer: Option C
#include
class Number
{
int Num;
public:
Number(int x = 0)
{
Num = x;
}
void Display(void)
{
cout<< Num;
}
void Modify();
};
void Number::Modify()
{
int Dec;
Dec = Num % 13;
Num = Num / 13;
if(Num > 0 ) Modify() ;
if(Dec == 10) cout<< "A" ;
else if(Dec == 11) cout<< "B" ;
else if(Dec == 12) cout<< "C" ;
else if(Dec == 13) cout<< "D" ;
else cout<< Dec ;
}
int main()
{
Number objNum(130);
objNum.Modify();
return 0;
}
[A].10
[B].20
[C].30
[D].40
Answer: Option C
Answer: Option C
Destructor destroys only float data members of the object.
[C].
Destructor destroys only pointer data members of the object.
[D].
Destructor destroys the complete object.
Answer: Option D
Explanation:
No answer description available for this question.
#include
struct MyStructure
{
class MyClass
{
public:
void Display(int x, float y = 97.50, char ch = 'a')
{
cout<< x << " " << y << " " << ch;
}
}Cls;
}Struc;
int main()
{
Struc.Cls.Display(12, 'b');
return 0;
}
[A].The program will print the output 12 97.50 b.
[B].The program will print the output 12 97.50 a.
[C].The program will print the output 12 98 a.
[D].The program will print the output 12 Garbage b.
Answer: Option C
6 6 5
[C].
5 40 38
[D].
6 40 38
Answer: Option D
Explanation:
No answer description available for this question.
#include
class Bix
{
public:
int x;
};
int main()
{
Bix *p = new Bix();
(*p).x = 10;
cout<< (*p).x << " " << p->x << " " ;
p->x = 20;
cout<< (*p).x << " " << p->x ;
return 0;
}
[A].10 10 20 20
[B].Garbage garbage 20 20
[C].10 10 Garbage garbage
[D].Garbage garbage Garbage garbage
Answer: Option A