2011-11-25

What are OOPS Principles ?

OOPS principles are design patters those suggest how we should develop program to organize and reuse effectively with high scalability.The programming language that supports below principles is called as object oriented programming language.

1) Encapsulation
2) Inheritance
3) Polymorphism

Java supports Abstraction which is the backbone of all the above three oops principles. It is the supporting principle of OOPS that ensures all three principles working together to give final shape of the project.

Encapsulation:

The process of hiding internal data from the outside world and accessing it only through publicly exposed methods is known as data encapsulation.Let us take an example

In the above diagram father earns 1 crore per annum and deposited that money in bank in mothers account to protect it and withdrawing it later with proper authentication.This is called encapsulation.

Inheritance:

The process of reusing class members from another class as if it were defined in that class is called inheritance. It can also be defined as it is a process of obtaining one object property to other object is called inheritance
In the above diagram father is earning 1 crore per annum and one of the child reusing father's money in his/her own business to get more money or just spending it for enjoyment just like child 2 in the above diagram.This is called inheritance.

Polymorphism:

Having multiple forms of a method with same name is called polymorphism.

In the world so many persons will have the same name 'arnold' .This is called polymorphism.

Abstraction:

The process of removing or hiding unnecessary information is called abstraction.The process of providing necessary method prototype by removing/hiding unnecessary method logic is called as abstraction. Let us take an example
In the above diagram if we enter into books stall and if we ask shopkeeper for java books then he shows only     java books hiding the unnecessary information and from that 100 books if we select 50 books that we like then another unnecessary 50 books he hides.Finally we select one book and remaining 49 books he hides.This is called abstraction


Comment for any doubts.......

Loading

Enter your Email here: