Posts

Comparison between Inheritance and Polymorphism

Image
  Java is object-oriented programming language. There are 4 characteristics of object-oriented languages which are: Polymorphism, Inheritance, Encapsulation, Abstraction. Polymorphism -Polymorphism refers to the ability of OOPs programming languages to differentiate between entities with the same name efficiently. Inheritance -Inheritance is an important pillar of OOP (Object Oriented Programming). It is the mechanism in java by which one class is allowed to inherit the features (fields and methods) of another class. Encapsulation -Encapsulation is defined as the wrapping up of data under a single unit . It is the process of keeping classes private so that they cannot be changed by external code. Abstraction -Data Abstraction is the property by virtue of which only the essential details are displayed to the user. Difference Between Polymorphism and Inheritance Polymorphism occurs when there are two or more distinctly different traits in the same population of species, or th...