Which of the following feature of OOPs is not used in the following C++ code?

class A
{
    int i;
    public:
    void print(){cout<<"hello"<<i;}
}
 
class B: public A
{
    int j;
    public:
    void assign(int a){j = a;}
}

a) Abstraction
b) Encapsulation
c) Inheritance
d) Polymorphism

1 thought on “Which of the following feature of OOPs is not used in the following C++ code?”

  1. d
    Explanation: As i and j members are private i.e. they are hidden from outer world therefore we have used the concept of abstraction. Next data members and there related functions are put together into single class therefore encapsulation is used. Also as class B is derived from A therefore Inheritance concept is used. But as no function is overloaded in any of the classes therefore, the concept of polymorphism is missing here.

Leave a Comment