The first two Inheritance and polymorphism has been pretty straight to understand,
- Inheritance à the child class get the properties of the parent class, and so on
- Polymorphism -> the object behaves differently in different situations basically polymorphic, it can be achieved by over loading and with help of inheritance and overriding concepts.
Coming to the Abstraction and encapsulation, they both are bit confusing.
Both are telling to hide some information. But ways are different.
- Encapsulation suggests to hides the information by restricting the access of the class, methods, members.
- Abstraction suggests to hides the information, (actual implementation of the objects behaviour) By using the Interfaces and abstract classes to show the behaviours (public methods) and you implement them in concrete classes. So that the client only sees the public methods, you can always improve the concrete implementations in later versions.
What are the advantages we get if we follow Oops principles?
Well you can develop better software.
- Flexibility – always possible to provide more advance implementations
- Modular – so parallel development possible, easy to debug without effecting other modules
- Easy to maintain
- Makes easy for performance tuning
- Code reusability
- The entire system mail fail but the individual module may work properly so we can always make things right.