+ 10
Is there any relationship between Polymorphism👈Abstraction💚 Inheritance💞💝 and Composition🤔🤔
5 Answers
+ 9
Polymorphism occurs when there is a hierarchy of classes related to each other through inheritance.
Abstraction is used when there is no meaningful definition for the method in the superclass.
+ 1
All these things are used to create more complex code.
Abstraction in this context means something without any specific details of the implementation, hence a class with a pure virtual function cannot be instantiated.
Composition occurs when you put some class or structure into another.
Inheritance occurs when you derive a class from other and Polymorphism when you override a behavior, a method, of the base class.
0
those are interrelated through oops concepts...
though each have their own task
...polymorphism Ellesmere to use one function act differently
...Inheritance enables us to inherit features from the base class, whereas
... abstraction leads us to focus on only essential parts
0
Association is another fundamental relationship between classes that is informally known as “Has-A” relationship.
When an object of one class is created as data member inside another class, it is called association relationship in java or simply Has-A relationship.
Look at the above figure where an object of class A is created as data member inside another class B. This relationship is known as Has-A relationship. It is easy to understand and makes a stronger form of dependency.
Inheritance (“Is-A”) Relationship in Java
________________________________________
Inheritance represents Is-a relationship in Java. It establishes a relationship between a more general class (known as superclass) and a more specialized class (known as subclass).
In other words, Is-A relationship defines the relationship between two classes in which one class extends another class.
Look at the above figure where a class B makes a relationship with class A by the keyword “extends” and can inherit data members from class A.
- 2
Oops