Data Encapsulation
Data Encapsulation
Data Encapsulation is an important feature of OOPs that enables us to combine / put together related data and functions.
Abstraction
Abstraction
Functions provide a way to abstract implementation details. But OOPs provide next level abstraction through classes and objects.
TODO(“Abstraction Example”)
Suppose we have a function countWords(text: String): Int
which counts & returns the number of words in the given text. By creating this function, we have abstracted the implementation details to the function. Once defined, this function helps us do what we want to do without knowing how to do it.
- Polymorphism
- Reusability
- Data Security