Welcome to the Classes and Operator Overloading in C++ MCQs Page
Dive deep into the fascinating world of Classes and Operator Overloading in C++ with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Classes and Operator Overloading in C++, a crucial aspect of Object Oriented Programming Using C++. In this section, you will encounter a diverse range of MCQs that cover various aspects of Classes and Operator Overloading in C++, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Object Oriented Programming Using C++.
Check out the MCQs below to embark on an enriching journey through Classes and Operator Overloading in C++. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Object Oriented Programming Using C++.
Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Classes and Operator Overloading in C++. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!
Classes and Operator Overloading in C++ MCQs | Page 30 of 39
Explore more Topics under Object Oriented Programming Using C++
#include<iostream.h>
class Compscibits
{
int x, y;
public:
Compscibits(int xx = 10, int yy = 20 )
{
x = xx;
y = yy;
}
void Display()
{
cout<< x << " " << y << endl;
}
~Compscibits()
{ }
};
int main()
{
Compscibits objBits;
objBits.Display();
return 0;
}
#include<iostream.h>
class Compscibits
{
int x;
public:
Compscibits(short ss)
{
cout<< "Short" << endl;
}
Compscibits(int xx)
{
cout<< "Int" << endl;
}
Compscibits(char ch)
{
cout<< "Char" << endl;
}
~Compscibits()
{
cout<< "Final";
}
};
int main()
{
Compscibits *ptr = new Compscibits('B');
return 0;
}
#include<iostream.h>
class Compscibits
{
int x;
public:
Compscibits(short ss)
{
cout<< "Short" << endl;
}
Compscibits(int xx)
{
cout<< "Int" << endl;
}
Compscibits(float ff)
{
cout<< "Float" << endl;
}
~Compscibits()
{
cout<< "Final";
}
};
int main()
{
Compscibits *ptr = new Compscibits('B');
return 0;
}#include<iostream.h>
class BitsBase
{
public:
BitsBase()
{
cout<< "Base OK. ";
}
~BitsBase()
{
cout<< "Base DEL. ";
}
};
class BitsDerived: public BitsBase
{
public:
BitsDerived()
{
cout<< "Derived OK. ";
}
~BitsDerived()
{
cout<< "Derived DEL. ";
}
};
int main()
{
BitsBase *basePtr = new BitsDerived();
delete basePtr;
return 0;
}
#include<iostream.h>
class BitsBase
{
public:
BitsBase()
{
cout<< "Base OK. ";
}
virtual ~BitsBase()
{
cout<< "Base DEL. ";
}
};
class BitsDerived: public BitsBase
{
public:
BitsDerived()
{
cout<< "Derived OK. ";
}
~BitsDerived()
{
cout<< "Derived DEL. ";
}
};
int main()
{
BitsBase *basePtr = new BitsDerived();
delete basePtr;
return 0;
}
#include<iostream.h>
class BitsBase
{
public:
int x, y;
BitsBase(int xx = 0, int yy = 5)
{
x = ++xx;
y = --yy;
}
void Display()
{
cout<< --y;
}
~BitsBase(){}
};
class BitsDerived : public BitsBase
{
public:
void Increment()
{
y++;
}
void Display()
{
cout<< --y;
}
};
int main()
{
BitsDerived objBits;
objBits.Increment();
objBits.Display();
return 0;
}
#include<iostream.h>
class BitsBase
{
protected:
int x, y;
public:
BitsBase(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
}
void Show()
{
cout<< x * this->y << endl;
}
};
class BitsDerived
{
private:
BitsBase objBase;
public:
BitsDerived(int xx, int yy) : objBase(xx, yy)
{
objBase.Show();
}
~BitsDerived()
{ }
};
int main()
{
BitsDerived objDev(10, 20);
return 0;
}
#include<iostream.h>
class Compscibits
{
int x;
public:
Compscibits()
{
x = 0;
}
Compscibits(int xx)
{
x = xx;
}
Compscibits(Compscibits &objB)
{
x = objB.x;
}
void Display()
{
cout<< x << " ";
}
};
int main()
{
Compscibits objA(25);
Compscibits objB(objA);
Compscibits objC = objA;
objA.Display();
objB.Display();
objC.Display();
return 0;
}
#include<iostream.h>
class Compscibits
{
int x, y;
public:
Compscibits()
{
x = 0;
y = 0;
}
Compscibits(int xx, int yy)
{
x = xx;
y = yy;
}
Compscibits(Compscibits *objB)
{
x = objB->x;
y = objB->y;
}
void Display()
{
cout<< x << " " << y;
}
};
int main()
{
Compscibits objBits( new Compscibits(20, 40) );
objBits.Display();
return 0;
}
#include<iostream.h>
class BitsBase
{
public:
int x, y;
public:
BitsBase(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
}
};
class BitsDerived : public BitsBase
{
private:
BitsBase objBase;
public:
BitsDerived(int xx, int yy) : BitsBase(xx), objBase(yy)
{
cout << this->x << " "
<< this->y << " "
<< objBase.x << " "
<< objBase.y << " ";
}
~BitsDerived()
{ }
};
int main()
{
BitsDerived objDev(11, 22);
return 0;
}
#include<iostream.h>
class BitsBase
{
public:
int x, y;
public:
BitsBase(int xx = 0, int yy = 0)
{
x = xx;
y = yy;
}
};
class BitsDerived : public BitsBase
{
private:
BitsBase objBase;
public:
BitsDerived(int xx, int yy) : BitsBase(xx), objBase(yy)
{
cout << x << " "
<< this->x << " "
<< BitsBase::x << " "
<< this->objBase.x ;
}
~BitsDerived()
{ }
};
int main()
{
BitsDerived objDev(11, 22);
return 0;
}
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!
Cyber Security
Understand the fundamentals of safeguarding digital assets with our Cyber Security...
Operating System
Dive deep into the core of computers with our Operating System MCQs. Learn about...