Cpp Programming 98 – Which of the following concepts of OOPS means exposing only necessary information to client?
[B]. Abstraction
[D]. Data binding
Answer: Option C
Answer: Option C
#include
class Point
{
int x, y;
public:
Point(int xx = 10, int yy = 20)
{
x = xx;
y = yy;
}
Point operator + (Point objPoint)
{
Point objTmp;
objTmp.x = objPoint.x + this->x;
objTmp.y = objPoint.y + this->y;
return objTmp;
}
void Display(void)
{
cout<< x << " " << y;
}
};
int main()
{
Point objP1;
Point objP2(1, 2);
Point objP3 = objP1 + objP2;
objP3.Display();
return 0;
}
[A]. 1 2
[B]. 10 20
Answer: Option C
Cpp Programming 100 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes#include
class A
{
public:
void BixFunction(void)
{
cout<< "Class A" << endl;
}
};
class B: public A
{
public:
void BixFunction(void)
{
cout<< "Class B" << endl;
}
};
class C : public B
{
public:
void BixFunction(void)
{
cout<< "Class C" << endl;
}
};
int main()
{
A *ptr;
B objB;
ptr = &objB;
ptr = new C();
ptr->BixFunction();
return 0;
}
[A].Class A.
[B].Class B.
[C].Class C.
[D].The program will report compile time error.
Answer: Option A
Cpp Programming Quiz 101 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes#include
class IndiaBix
{
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 IndiaBix::count = 0;
int main()
{
IndiaBix :: First();
IndiaBix :: Second(5);
IndiaBix :: Display();
return 0;
}
[A].0
[B].5
[C].10
[D].15
Answer: Option D
Cpp Programming Quiz 102 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes#include
#include
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;
}
[A].2
[B].3
[C].5
[D].8
Answer: Option B
Cpp Programming Quiz 103 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes#include
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;
}
[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: Option C
#include
#include
class IndiaBix
{
char str[50];
char tmp[50];
public:
IndiaBix(char *s)
{
strcpy(str, s);
}
int BixFunction()
{
int i = 0, j = 0;
while(*(str + i))
{
if(*(str + i++) == ' ')
*(tmp + j++) = *(str + i);
}
*(tmp + j) = 0;
return strlen(tmp);
}
};
int main()
{
char txt[] = "Welcome to IndiaBix.com!";
IndiaBix objBix(txt);
cout<< objBix.BixFunction();
return 0;
}
[A].1
[B].2
[C].24
[D].25
Answer: Option B
Cpp Programming Quiz 105 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes#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
Cpp Programming Quiz 106 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes#include
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: Option A
Cpp Programming Quiz 107 – What will be the output of the following program? Read More »
Cpp Programming, Objects And Classes