Object Oriented Programming (OOP) is a programming model that replicates real world objects.Objects are the building blocks in object-oriented programming provides high level of data integrity. As explained in previous post .The main principles of object-oriented programming language are
Inheritance : As the name inheritance suggests it is the property of once object to inherit the properties of another object .The objects can be modified to acquire additional features by inheriting properties of another object to its already existing property
Examples of inheritance:
Well, we will take example of animals.Yeah,animals are a good example .Under animals we have to name a few dogs ,cats and cows,under dos,there are many breeds.Dogs inherit some of the properties of the class animals,similarly different breeds of dogs inherit properties of the class fogs.
Encapsulation : the working details of the objects are hidden from the user.This is called encapsulation.The main aim is to provide support to end user.He need not to kow the internal working of the procedure.It prevents the objects being tampered by the user.
Let us now take examples of encapsulation
Example 1 :
Take the example of driving a car.You insert the ignition key,start the car and drive along.The powering details of the car are not known by you.
Example 2 :A user detects a command from a menu to perform certain action the action is performed but the code that performs the action is hidden from the user.
Abstraction is the basically hiding data that ate not needed for presentation.Abstraction is to separate the behaviour of an object from the actual details that implements the object’s behaviour.
When a customer wants to buy a car.He will look at the different features such as it’s performance.Shape,colour,average,engine,quality,company and so on.He is not interpreted in knowing the working mechanism of the car.Like what actually make the car run.How fuel runs car etc .
Polymorphism :- In Greek,”poly” means many and morph means shape.Hence.Polymorphism is the ability of an object to behave differently under different situations.Same message when sent to different object,the behaviour depends on the object receiving its message.It reduces the coding involved while modifying an application.
Human beings.Under human beings we can have Indian Americans,Canadians,Africans and Australians .And under Indians we can have Gujarati, Punjabi, Knanadigas,Tamilians.Haryanvi,Gujarati,Maharati ,Bengali Etc . When they talk,Gujarati will talk in Gujarati ,Punjabi will talk in Punjabi .Now the word talk assumes different forms under different circumstances.
So this was about the principles of OOP. Well,I have tried my level best to explain it in as short as I can.However,if you face any problem ,kindly comment and ask, i would be glad to reply you.