Sail E0 Webinar

MCQs

Total Questions : 10
Question 1.

Where does the abstract class is used?


  1.    base class only
  2.    derived class
  3.    both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> base class only

None.


Question 2.

Pick out the correct option.


  1.    We cannot make an instance of an abstract base class
  2.    We can make an instance of an abstract base class
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> We cannot make an instance of an abstract base class

None


Question 3.

What is meant by pure virtual function?


  1.    Function which does not have definition of its own.
  2.    Function which does have definition of its own.
  3.    Function which does not have any return type.
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> Function which does not have definition of its own.

As the name itself implies, it have to depend on other class only.


Question 4.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class Base
4.
{
5.
public:
6.
virtual void print() const = 0;
7.
};
8.
class DerivedOne : virtual public Base
9.
{
10.
public:
11.
void print() const
12.
{
13.
cout
  1.    121
  2.    212
  3.    12
  4.    None of the mentioned
 Discuss Question
Answer: Option B. -> 212

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


Question 5.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class sample
4.
{
5.
public:
6.
virtual void example() = 0;
7.
};
8.
class Ex1:public sample
9.
{
10.
public:
11.
void example()
12.
{
13.
cout example();
33.
}
  1.    ubuntu
  2.    is awesome
  3.    ubuntu is awesome
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> ubuntu is awesome

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


Question 6.


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class MyInterface
4.
{
5.
public:
6.
virtual void Display() = 0;
7.
};
8.
class Class1 : public MyInterface
9.
{
10.
public:
11.
void Display()
12.
{
13.
int a = 5;
14.
cout
  1.    5
  2.    10
  3.    5 5
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> 5 5

In this program, We are displaying the data from the two classes
by using abstract class.
Output:
$ g++ abs1.cpp
$ a.out
5 5


Question 7.


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.
}
  1.    1020
  2.    20
  3.    10
  4.    2010
 Discuss Question
Answer: Option D. -> 2010

In this program, We are calculating the area of rectangle and
triangle by using abstract class.
Output:
$ g++ abs.cpp
$ a.out
2010


Question 8.

Which is used to create a pure virtual function ?


  1.    $
  2.    =0
  3.    &
  4.    !
 Discuss Question
Answer: Option B. -> =0

For making a method as pure virtual function, We have to append '=0' to the class or method.



Question 9.

Which is also called as abstract class?


  1.    virtual function
  2.    pure virtual function
  3.    derived class
  4.    derived class
 Discuss Question
Answer: Option B. -> pure virtual function

Classes that contain at least one pure virtual function are called as abstract base classes.


Question 10.

Which class is used to design the base class?


  1.    abstract class
  2.    derived class
  3.    derived class
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> abstract class

None.


Latest Videos

Latest Test Papers