OOPs Concept
Inheritance: When one object acquires all the properties and behaviors of parent object i.e. known as inheritance. It provides code re usability.
Inheritance having two types (Inheritance) IS-A and (Composition) HAS-A:
IS-A: This relationship is easy to identify. In real world, car is a vehicle. Car extends all the properties of vehicle and implements vehicle’s behavior. In java world, where ever extends and implements keyword is used with class name, defines IS-A relationship.
This relationship is uni-directional. Means, Car is vehicle but a vehicle never be a car.
HAS-A: In real world, car has AC, stereo etc from car accessories. In java world, when any instance variable use in some other class known as HAS-A relationship.
Poly morph-ism: It is very simple to understand, one name but many forms. Like in real world, we have bicycles. But, there are so many types of them. Only having little changes and there functionality is totally changed just because of some of having gear, light, GPS etc. In java world, overloading and overriding are example of poly morph-ism.
Encapsulation: This is known as binding or wrapper data together into a single unit. The best and simple example is capsule, having different type of medicine into a single capsule. In java world, bean class is best example of encapsulation. All the members are in a single class and all are private.
Abstraction: Hiding internal details and showing functionality is known as abstraction. Like we have car we always drive but don’t know how it starts. In java world, we use abstract classes and interface to implement abstraction.
So till now, we have learned basic features, elements and flow and java program. Now you are able to make a simple program implementing all OOPS concepts.
Inheritance: When one object acquires all the properties and behaviors of parent object i.e. known as inheritance. It provides code re usability.
Inheritance having two types (Inheritance) IS-A and (Composition) HAS-A:
IS-A: This relationship is easy to identify. In real world, car is a vehicle. Car extends all the properties of vehicle and implements vehicle’s behavior. In java world, where ever extends and implements keyword is used with class name, defines IS-A relationship.
This relationship is uni-directional. Means, Car is vehicle but a vehicle never be a car.
HAS-A: In real world, car has AC, stereo etc from car accessories. In java world, when any instance variable use in some other class known as HAS-A relationship.
Poly morph-ism: It is very simple to understand, one name but many forms. Like in real world, we have bicycles. But, there are so many types of them. Only having little changes and there functionality is totally changed just because of some of having gear, light, GPS etc. In java world, overloading and overriding are example of poly morph-ism.
Encapsulation: This is known as binding or wrapper data together into a single unit. The best and simple example is capsule, having different type of medicine into a single capsule. In java world, bean class is best example of encapsulation. All the members are in a single class and all are private.
Abstraction: Hiding internal details and showing functionality is known as abstraction. Like we have car we always drive but don’t know how it starts. In java world, we use abstract classes and interface to implement abstraction.
So till now, we have learned basic features, elements and flow and java program. Now you are able to make a simple program implementing all OOPS concepts.
No comments:
Post a Comment
Thank you for your comments.