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 26

We can create objects of the abstract class. 

True

 False
SHOW ANSWER

Which of the following is true about virtual functions in C++.

Virtual functions are functions that can be overridden in derived class with the same signature.

Virtual functions enable run-time polymorphism in a inheritance hierarchy.

If a function is ‘virtual’ in the base class, the most-derived class’s implementation of the function is called according to the actual type of the object referred to, regardless of the declared type of the pointer or reference.
In non-virtual functions, the functions are called according to the type of reference or pointer.

 All of the above
SHOW ANSWER

Which of the following is true about pure virtual functions?
1) Their implementation is not provided in a class where they are declared.
2)If a class has a pure virtual function, then the class becomes abstract class and an instance of this class cannot be created.

Both 1 and 2

Only 1

 Only 2

 Neither 1 nor 2
SHOW ANSWER

Can static functions be virtual? Will the following program compile?
#include<iostream> 
using namespace std;    
class Test
{
   public:
      virtual static void fun()  { }
};

Yes

 No
SHOW ANSWER

Which among the following best describes polymorphism?

It is the ability for a message/data to be processed in more than one form

It is the ability for a message/data to be processed in only 1 form

It is the ability for many messages/data to be processed in one way

It is the ability for undefined message/data to be processed in at least one way
SHOW ANSWER

What do you call the languages that support classes but not polymorphism?

Class based language

Procedure Oriented language

Object-based language

If classes are supported, polymorphism will always be supported
SHOW ANSWER

Which among the following is the language which supports classes but not polymorphism?

SmallTalk

Java

C++

Ada
SHOW ANSWER

If same message is passed to objects of several different classes and all of those can respond in a different way, what is this feature called?

Inheritance

Overloading

Polymorphism

Overriding
SHOW ANSWER

Which class/set of classes can illustrate polymorphism in the following code:
abstract class student
{
   public : int marks;
   calc_grade();
}
class topper:public student
{
    public : calc_grade()
    { 
        return 10; 
    }
};
class average:public student

     public : calc_grade()
     {
         return 20; 
     }
};
class failed{ int marks; };

Only class student can show polymorphism

Only class student and topper together can show polymorphism

class student, topper and average together can show polymorphism

Class failed should also inherit class student for this code to work for polymorphism
SHOW ANSWER

Which type of function among the following shows polymorphism?

Inline function

Virtual function

Undefined functions

Class member functions
SHOW ANSWER

In case of using abstract class or function overloading, which function is supposed to be called first?

Local function

Function with highest priority in compiler

Global function

Function with lowest priority because it might have been halted since long time, because of low priority
SHOW ANSWER

Which among the following can’t be used for polymorphism?

Static member functions

Member functions overloading

Predefined operator overloading

Constructor overloading
SHOW ANSWER

What is output of the following program?
class student

    public : int marks; 
    void disp() 
    { 
        cout<<”its base class”
    };
    class topper:public student
    {
        public : 
        void disp()
        { 
            cout<<”Its derived class”; 
        }
    }
    void main() { student s; topper t;
    s.disp();
    t.disp();

Its base classIts derived class

Its base class Its derived class

Its derived classIts base class

Its derived class Its base class
SHOW ANSWER

Which among the following can show polymorphism?

Overloading ||

Overloading +=

Overloading &&
SHOW ANSWER

Find the output of the program:
class education

    char name[10];
    public : disp()
    { 
        cout<<”Its education system”;
    }
    class school:public education
    {
        public: void dsip()
        { 
            cout<<”Its school education system”;
        }
    };
    void main()
    {
                school s;
                s.disp();
    }
}

Its school education system

Its education system

Its school education systemIts education system

Its education systemIts school education system
SHOW ANSWER

Which problem may arise if we use abstract class functions for polymorphism?

All classes are converted as abstract class

Derived class must be of abstract type

Derived classes can’t redefine the function
SHOW ANSWER

Which among the following is not true for polymorphism?

It is feature of OOP

Ease in readability of program

Helps in redefining the same functionality

Increases overhead of function definition always
SHOW ANSWER

If 2 classes derive one base class and redefine a function of base class, also overload some operators inside class body. Among these two things of function and operator overloading, where is polymorphism used?

Function overloading only

Operator overloading only

Both of these are using polymorphism

Either function overloading or operator overloading because polymorphism can be applied only once in a program
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