MCQOPTIONS
Bookmark
Saved Bookmarks
→
C++ Programming
→
Constructors And Destructors in C++ Programming
→
How many types of class are there in c++?..
1.
How many types of class are there in c++?
A.
4
B.
3
C.
2
D.
1
E.
None of these
Answer» C. 2
Show Answer
Discussion
No Comment Found
Post Comment
Related MCQs
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class InterfaceClass <br> {<br> public:<br> virtual void Display() = 0;<br> };<br> class ClassA : public InterfaceClass <br> {<br> public:<br> void Display() <br> {<br> int num = 10;<br> cout << num;<br> }<br> };<br> class ClassB : public InterfaceClass <br> {<br> public:<br> void Display()<br> {<br> cout < }<br> };<br> int main()<br> {<br> ClassA object1;<br> object1.Display();<br> ClassB object2;<br> object2.Display();<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class FirstClass<br> {<br> protected:<br> int width, height;<br> public:<br> void set_values (int x, int y)<br> {<br> width = x; height = y; <br> }<br> virtual int area (void) = 0;<br> };<br> class SecondClass: public FirstClass<br> {<br> public:<br> int area (void)<br> { <br> return (width * height);<br> }<br> };<br> class ThirdClass: public FirstClass <br> {<br> public:<br> int area (void)<br> {<br> return (width * height / 2); <br> }<br> };<br> int main () <br> {<br> SecondClass Rectangle;<br> ThirdClass trgl;<br> FirstClass * ppoly1 = &Rectangle;<br> FirstClass * ppoly2 = &trgl;<br> ppoly1->set_values (3, 6);<br> ppoly2->set_values (3, 6);<br> cout << ppoly1 -> area() < cout << ppoly2 -> area();<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class Base <br> {<br> int K;<br> public:<br> void setInt(int num);<br> int getInt();<br> };<br> class Derived : public Base<br> {<br> int L;<br> public:<br> void setL(int num);<br> int multiply();<br> };<br> void Base::setInt(int num)<br> {<br> K = num;<br> }<br> int Base::getInt()<br> {<br> return K;<br> }<br> void Derived::setL(int num)<br> {<br> L = num;<br> }<br> int Derived::multiply()<br> {<br> return L * getInt();<br> }<br> int main()<br> {<br> Derived object;<br> object.setInt(12); <br> object.setL(3); <br> cout << object.multiply(); <br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class BaseClass <br> {<br> public:<br> virtual void Function()<br> {<br> cout << "4";<br> }<br> };<br> class DerivedClassA : public BaseClass <br> {<br> public:<br> void Function()<br> {<br> cout << " 5";<br> }<br> };<br> class DerivedClassB : public DerivedClassA <br> {<br> public:<br> void Function()<br> {<br> cout << " 6";<br> }<br> };<br> int main()<br> {<br> BaseClass *ptr;<br> BaseClass BaseObject;<br> DerivedClassA derivedObjectA;<br> DerivedClassB derivedObjectB;<br> ptr = &BaseObject;<br> ptr -> Function();<br> ptr = &derivedObjectA;<br> ptr -> Function();<br> ptr = &derivedObjectB;<br> ptr -> Function();<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class BaseClass <br> {<br> int A;<br> public:<br> void setA(int num1) <br> {<br> A = num1;<br> }<br> void showA() <br> {<br> cout << A < }<br> };<br> class DerivedClass : private BaseClass<br> {<br> int B;<br> public:<br> void setAB(int num1, int num2)<br> {<br> setA(num1); <br> B = num2;<br> }<br> void showAB() <br> {<br> showA(); <br> cout << B << ' n';<br> }<br> };<br> int main()<br> {<br> DerivedClass object;<br> object.setAB(15, 25);<br> object.showAB();<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class BaseClass<br> {<br> public:<br> BaseClass(){}<br> ~BaseClass(){}<br> protected:<br> private: <br> };<br> class DerivedClass:public BaseClass<br> {<br> public:<br> DerivedClass(){}<br> DerivedClass(){}<br> private:<br> protected:<br> };<br> int main()<br> {<br> cout << "The program exceuted" << endl;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> #include <sstream><br> using namespace std;<br> int main()<br> {<br> stringstream strstream(ios :: in | ios :: out);<br> std :: string data("The double value is : 12.25 .");<br> strstream.str(data);<br> strstream.seekg(-5, ios :: end);<br> double value;<br> strstream >> value;<br> value = value*value;<br> strstream.seekp(-5,ios::end);<br> strstream << value;<br> std :: string new_value = strstream.str();<br> cout << new_value;<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class Polygon<br> {<br> protected:<br> int W, H;<br> public:<br> void set_values(int width, int height)<br> {<br> W = width; H = height;<br> }<br> };<br> class Coutput<br> {<br> public:<br> void output(int i);<br> };<br> void Coutput::output(int i)<br> {<br> cout << i < }<br> class Rectangle:public Polygon, public Coutput<br> {<br> public:<br> int area()<br> {<br> return(W * H);<br> }<br> };<br> class Triangle:public Polygon, public Coutput<br> {<br> public:<br> int area()<br> {<br> return(W * H / 2);<br> }<br> };<br> int main()<br> {<br> Rectangle Rect;<br> Triangle trgl;<br> Rect.set_values(5, 2);<br> trgl.set_values(5, 2);<br> Rect.output(Rect.area());<br> trgl.output(trgl.area());<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class student<br> {<br> protected:<br> int Rollno;<br> public:<br> void get_Rollno(int num)<br> {<br> Rollno = num;<br> }<br> void put_Rollno(void)<br> {<br> }<br> };<br> class test:public student<br> {<br> protected:<br> float Subject1,Subject2;<br> public:<br> void get_mark(float num1, float num2)<br> {<br> Subject1 = num1;<br> Subject2 = num2;<br> }<br> void put_marks()<br> {<br> }<br> };<br> class sports<br> {<br> protected:<br> float score;<br> public:<br> void getscore(float s)<br> {<br> score = s;<br> }<br> void putscore(void)<br> {<br> }<br> };<br> class result: public test, public sports<br> {<br> float total;<br> public:<br> void display(void);<br> };<br> void result::display(void)<br> {<br> total = Subject1 + Subject2 + score;<br> put_Rollno();<br> put_marks();<br> putscore();<br> cout << "Total Score = " << total << " n";<br> }<br> int main()<br> {<br> result student;<br> student.get_Rollno(101);<br> student.get_mark(50.25, 42.52);<br> student.getscore(7.0);<br> student.display();<br> return 0;<br> }<br></pre>
What is the output of this program?<br><pre class="prettyprint lang-c">#include <iostream><br> using namespace std;<br> class BaseClass<br> {<br> public:<br> virtual void print() const = 0;<br> };<br> class DerivedClassA : virtual public BaseClass<br> {<br> public:<br> void print() const<br> {<br> cout << " 5 ";<br> }<br> };<br> class DerivedClassB : virtual public BaseClass<br> {<br> public:<br> void print() const<br> {<br> cout << "3";<br> }<br> };<br> class Multiple : public DerivedClassA, DerivedClassB<br> {<br> public:<br> void print() const<br> {<br> DerivedClassB::print();<br> }<br> };<br> int main()<br> {<br> Multiple both;<br> DerivedClassA objectA;<br> DerivedClassB objectB;<br> BaseClass *array[ 3 ];<br> array[ 0 ] = &both;<br> array[ 1 ] = &objectA;<br> array[ 2 ] = &objectB;<br> for ( int K = 0; K < 3; K++ )<br> array[ K ] -> print();<br> return 0;<br> }<br></pre>
Reply to Comment
×
Name
*
Email
*
Comment
*
Submit Reply