So I'm quite new to OOP and Java in general. I've been going through my textbook on the 4 most fundamental concepts of OOP programming but it's quite confusing.
The textbooks states "A class can change its functioning or variable type and the user would not need to change their code" as an advantage of Encapsulation, but to me that sounds like Abstraction...
Also, the textbook lists Overriding and Overloading as forms of inheritance but Google is telling that Overriding and Overloading are forms of Polymorphism.
Can someone clear this up for me?
You are fully right that it is abstraction which allows the implementation to change without affecting its user. However, encapsulation is a key feature in building bullet-proof abstractions: without it a user of your object stays independent of implementation only if he follows the convention never to access internal state of the object.
Overloading has definitely, positively, nothing to do with inheritance. It is a (weak) kind of polymorphism, but most of all, it is just an allowance to use the same name for several completely distinct methods. It has next to nothing to do with OOP and is fully applicable to any other programming paradigm, such as procedural or functional.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments