Abstract Class - Exp
Abstract Class - Exp
3. class p
4. {
5. protected:
7. public:
9. {
11. }
13. };
15. {
16. public:
18. {
20. }
21. };
23. {
24. public:
25. int area (void)
26. {
28. }
29. };
31. {
32. r rect;
33. t trgl;
40. return 0;
41. }
a) 1020
b) 20
c) 10
d) 2010
2. What will be the output of the following C++ code?
1. #include <iostream>
3. class MyInterface
4. {
5. public:
7. };
9. {
10. public:
12. {
13. int a = 5;
15. }
16. };
18. {
19. public:
21. {
23. }
24. };
28. obj1.Display();
30. obj2.Display();
31. return 0;
32. }
a) 5
b) 10
c) 5 5
d) 15
3. class sample
4. {
5. public:
7. };
9. {
10. public:
12. {
14. }
15. };
17. {
18. public:
20. {
22. }
23. };
25. {
29. arra[0]=&e1;
30. arra[1]=&e2;
31. arra[0]->example();
32. arra[1]->example();
33. }
a) ubuntu
b) is awesome
c) ubuntu is awesome
d) ubunt esome
4. What will be the output of the following C++ code?
1. #include <iostream>
3. class Base
4. {
5. public:
7. };
9. {
10. public:
12. {
14. }
15. };
17. {
18. public:
20. {
22. }
23. };
25. {
26. public:
28. {
29. DerivedTwo::print();
30. }
31. };
33. {
43. return 0;
44. }
a) 121
b) 212
c) 12
d) 215
5. What will be the output of the following C++ code?
#include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
a) Class B
b) Error
c) Segmentation fault
d) No output
6. #include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
int main(int argc, char const *argv[])
{
A a;
a.func();
return 0;
}
a) Class B
b) Error
c) Segmentation fault
d) No output
7. #include <iostream>
#include <string>
using namespace std;
class A
{
int a;
public:
virtual void func() = 0;
};
class B: public A
{
public:
void func(){
cout<<"Class B"<<endl;
}
};
a) Class B
b) Error
c) Segmentation fault
d) No output