C++ Programming
ABSTRACT CLASSES MCQs
Total Questions : 10
None.
None
As the name itself implies, it have to depend on other class only.
In this program, We are executing these based on the condition given in array. So it is printing as 212.
Output:
$ g++ abs4.cpp
$ a.out
212
In this program, We are combining the two statements from two classes and printing it by
using abstract class.
Output:
$ g++ abs3.cpp
$ a.out
ubuntu is awesome
In this program, We are displaying the data from the two classes
by using abstract class.
Output:
$ g++ abs1.cpp
$ a.out
5 5
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class p
4.
{
5.
protected:
6.
int width, height;
7.
public:
8.
void set_values (int a, int b)
9.
{
10.
width = a; height = b;
11.
}
12.
virtual int area (void) = 0;
13.
};
14.
class r: public
15.
{
16.
public:
17.
int area (void)
18.
{
19.
return (width * height);
20.
}
21.
};
22.
class t: public p
23.
{
24.
public:
25.
int area (void)
26.
{
27.
return (width * height / 2);
28.
}
29.
};
30.
int main ()
31.
{
32.
r rect;
33.
t trgl;
34.
p * ppoly1 = ▭
35.
p * ppoly2 = &trgl;
36.
ppoly1->set_values (4, 5);
37.
ppoly2->set_values (4, 5);
38.
cout area() ;
39.
cout area();
40.
return 0;
41.
}
In this program, We are calculating the area of rectangle and
triangle by using abstract class.
Output:
$ g++ abs.cpp
$ a.out
2010
For making a method as pure virtual function, We have to append '=0' to the class or method.
Classes that contain at least one pure virtual function are called as abstract base classes.
None.
Recent Questions
Q. Which Of The Following Methods Can Be Used For Manufacturing....
Q. Bromine Is A
Q. The Branch Current Method Is Based On Kirchhoff's Voltage La....
Q. Which Is The Shortcut Key To Jump To The First Slide Of The ....
Q. The Earliest Known Epigraphic Evidence Of Bhagvatism Is
Q. the Average Of First 10 Odd Numbers Is?
Q. Who Was The Architect Who Designed "Taj Mahal" ?
Q. Antonym Of Supernal ?
Q. The Arranging Of Data In A Logical Sequence Is Called
Q. Gopal Krishna Gokhale
Q. After You Wet Your Hands You Should Apply ______ And _____ F....
Q. The Practical Limit Of Moisture Content Achieved In Air Dryi....
Q. The Sieder-Tate Correlation For Heat Transfer In Turbulent F....
Q. Which Of The Following Is Not A Measure Of Product Deficienc....
Q. After Choosing A Predefined Template, Which Option Has To Be....
Q. Who Has Won The Best Actor Award At The 67th National Awards....
Q. The Rails Get Out Of Their Original Positions Due To Insuffi....
Q. The Unit Of Pressure Most Commonly Found On A Surface Weathe....
Q. The Charging Time Constant Of A Circuit Consisting Of An Ind....
Q. Which Of Following Is First Sign Of Colorectal Cancer?