Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

C++ - QUESTIONS : PART 27

 Run time polymorphism in C++ Program is

New and delete operator overloading

++ and – – operator overloading

:: operator overloading

None
SHOW ANSWER

Run time binding is related to

Function overriding


Operator overloading

A & B

None

SHOW ANSWER

63Which function cannot be overloaded in C++

Constructor

Class destructor

Both a & b

None

SHOW ANSWER

 Operators can be overloaded in C++ is/are

New

Delete

++

All can be overloaded
SHOW ANSWER

Which class is used to design the base class?

abstract class

derived class

base class

none of the mentioned
SHOW ANSWER

Which is used to create a pure virtual function ?

$

=0

&
SHOW ANSWER

Which is also called as abstract class?

virtual function

pure virtual function

 none of the mentioned
SHOW ANSWER

Which is also called as abstract class?
A. virtual function
B .pure virtual function
C. none of the mentioned
Answer:Option B
68. What is the output of this program?
 #include <iostream>
    using namespace std;
    class p 
    {
        protected:
        int width, height;
        public:
        void set_values (int a, int b)
        {
            width = a; height = b; 
        }
        virtual int area (void) = 0;
    };
    class r: public p
    {
        public:
        int area (void)
        { 
            return (width * height);
        }
    };
    class t: public p 
    {
        public:
        int area (void)
        {
            return (width * height / 2); 
        }
    };
    int main () 
    {
        r rect;
        t trgl;
        p * ppoly1 = &rect;
        p * ppoly2 = &trgl;
        ppoly1->set_values (4, 5);
        ppoly2->set_values (4, 5);
        cout << ppoly1 -> area() ;
        cout << ppoly2 -> area();
        return 0;
    }

1020

 20

 10

2010
SHOW ANSWER

What is the output of this program?

    #include <iostream>
    using namespace std;
    class MyInterface 
    {
        public:
        virtual void Display() = 0;
    };
    class Class1 : public MyInterface 
    {
        public:
        void Display() 
        {
            int  a = 5;
            cout << a;
        }
    };
    class Class2 : public MyInterface 
    {
        public:
        void Display()
        {
            cout <<" 5" << endl;
        }
    };
    int main()
    {
        Class1 obj1;
        obj1.Display();
        Class2 obj2;
        obj2.Display();
        return 0;
    }

5

10

5 5

None of the mentioned
SHOW ANSWER

What is the output of this program?
#include <iostream>
    using namespace std;
    class sample
    {
        public:
        virtual void example() = 0; 
    };
    class Ex1:public sample
    {
        public:
        void example()
        {
            cout << "ubuntu";
        }
    };
    class Ex2:public sample
    {
        public:
        void example()
        {
            cout << " is awesome";
        }
    };
    int main()
    {
        sample* arra[2];
        Ex1 e1;
        Ex2 e2;
        arra[0]=&e1;
        arra[1]=&e2;
        arra[0]->example();
        arra[1]->example();
    }

ubuntu

is awesome

ubuntu is awesome

none of the mentioned
SHOW ANSWER

What is the output of this program?
    #include <iostream>
    using namespace std;
    class Base
    {
        public:
        virtual void print() const = 0;
    };
    class DerivedOne : virtual public Base
    {
        public:
        void print() const
        {
            cout << "1";
        }
    };
    class DerivedTwo : virtual public Base
    {
        public:
        void print() const
        {
            cout << "2";
        }
    };
    class Multiple : public DerivedOne, DerivedTwo
    {
        public:
        void print() const
        {
            DerivedTwo::print();
        }
    };
    int main()
    {
        Multiple both;
        DerivedOne one;
        DerivedTwo two;
        Base *array[ 3 ];
        array[ 0 ] = &both;
        array[ 1 ] = &one;
        array[ 2 ] = &two;
        for ( int i = 0; i < 3; i++ )
        array[ i ] -> print();
        return 0;
    }

121

212

12

none of the mentioned
SHOW ANSWER

What is meant by pure virtual function?

Function which does not have definition of its own

Function which does have definition of its own

Function which does not have any return type

None of the mentioned
SHOW ANSWER

Pick out the correct option.

We cannot make an instance of an abstract base class

We can make an instance of an abstract base class

We can make an instance of an abstract super class

None of the mentioned
SHOW ANSWER

Where does the abstract class is used?

base class only

derived class

both derived & base class

 none of the mentioned
SHOW ANSWER

Compile time polymorphism in C++ language are

Operator overloading

Function overloading

Function overriding

B Only

A & B
SHOW ANSWER

C++ abstract class can contain

Pure virtual function

Non-virtual function

Only pure virtual function

Both pure virtual and non-virtual function
SHOW ANSWER

False statements about function overloading is

Defining multiple functions with same name in a class is called function overloading

Overloaded function must differ in their order and types of arguments.

Overloaded functions should be preceded with virtual keyword

No statement is false
SHOW ANSWER

Following keyword is used before a function in a base class to be overridden in derived class in C++

override

virtual

void

none
SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in