Principles of object oriented programming (Java)
Object Oriented Programming is a paradigm that gives many concepts such as which are being used in java :-
1. Object
2. Class
3. Polymorphism
4. Encapsulation
5. Inheritance
6. Abstraction
Object means real world entity such as bike, pen, phone etc. It is paradigm to design a program using objects and classes.
Object:
Any entity that has state and behavior is known as an object which can be physical or logical depends on your understanding.
Class:
Combination of multiple objects create a class.
Polymorphism:
"Poly" means "many" and "morph" means "form"
One task can be performed in different ways. For example: Creating something in different ways like in Automobile industry companies make different models of cars they can use this feature of polymorphism to achieve this functionality.
In java, we use method overloading (Compile time, Early binding, Static binding) and method overriding (Run time, Late binding, Dynamic binding).
Encapsulation:
Data Binding
Encapsulation is Wrapping data or code together in a single unit and keeps both safe from outside interference and misuse. Best Example is capsules made by doctors which have powder of several medicines wrapped.
Inheritance:
"Inheriting properties and behaviors of parent object"
Inheritance is the process by which one object acquires the properties of another object. Best feature of Inheritance is code re-usability. Extends keyword is used to inherit properties of base class.
Inheritance represents the IS-A relationship, also known as parent-child relationship.
Abstraction:
"Abstraction is used to hide certain details and show only essential features of object."
Ways to Achieve abstraction:
- Abstract class (0 to 100%)
- Interface (100%)
If you still have any question you can reach me any time through email (jigyasu2010@hotmail.com)
Comments
Post a Comment