Hi Guys !!! So this blog is all about the Object Oriented Programming concepts . Lets start from the very basic concept of Object and Class .
What is an Object ?
Well It is the most basic concept and a key to understand the Object-Oriented programming . Object is an entity that has two characteristics , State and Behavior . Some examples of real world object can be : Bike , Chair , Dog etc.
Lets take an example of a Bike . Bike has some state ( current gear , current speed ) and behavior ( change gear , apply brake ) . One way to begin thinking in an object-oriented way is to identify the state and behavior of real world objects .
Software objects are also similar to the real world objects. They too contains State and Behavior . An Object stores its state in fields and exposes the behavior through methods.
What is Class ?
Class is a blueprint from which objects of same type can be created . Lets take an example of a Bike again . There are thousands of bikes with the same characteristics i.e having same make and model . They are created from the same prototype / blueprint called class.
Now we know the basics of an Object and Class , so lets move on to Object Oriented principles
- Inheritance
- Polymorphism
- Abstraction
- Encapsulation
1. Inheritance :
Inheritance is the capability of one class to acquire the common state and behavior of another class while adding its own functionality . In Object Oriented programming , the concept of inheritance provides the idea of re-usability . This means we can add additional features to a class without modifying it.
How to achieve Inheritance in Java ?
extends keyword is used to inherit features of a class .
class Parent { // Parent has some state and behavior } class Child extends Parent { // Inherit the common state and behavior of Parent class. // Provide additional functionality. }
2. Polymorphism :
Polymorphism means ability of one type to take more than one form . This can also be applied in Java where in sub-classes of a class can define their own unique behaviors and yet share some of the common functionalites of the parent class.
Example :
Lets take an example of Bike . A company can produce different kind of bikes say , a mountain bike , and a roadbike . Now the two different types of bikes inherit the common features of a bike but also define their own separate features.
How to achieve Polymorphism in Java ?
Overloading and Overriding are the two ways to achieve Polymorphism.
3. Abstraction :
Abstraction is an essential element of Object Oriented programming . It refers to the act of presenting essential features without including the background details or explanations.
We can say that abstraction is purposeful suppression , hiding of some details of a process or artifact , in order to bring out more clearly other aspects , details or structures. Abstraction can be of control ( abstraction of actions ) or data .
How to achieve Abstraction in Java ?
Abstract classes and Interfaces are used to achieve Abstraction in Java.
4. Encapsulation :
Encapsulation is the binding of data and its associated functions in a single unit called Class . Access to the code and data inside the wrapper is tightly controlled through a well defined interface. Encapsulation provides a protective barrier that prevents the access of code and data from outside the class.
The main benefit of encapsulation is the ability to re-factor the implemented code without breaking the code of others and thus provides flexibility and maintainability .
Excellent Compilation of Question.
ReplyDeleteWill be very helpful.
Can you please add some question related to Filter ,Session management and Struts2?
Thanks
Arun
I liked your details very much. really good explanation. For every single details of java visit: java basic concepts
ReplyDeleteNice explanation easy to understanding every concept. but i need some examples. Java Training Chennai
ReplyDeleteJava Training In Chennai
ReplyDeleteNice article i was really impressed by seeing this article, it was very interesting and it is very useful for me.I get a lot of great information from this blog. Thank you for your sharing this informative blog.
Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
ReplyDeleteGreens Technologies In Chennai
ReplyDeleteThanks for sharing amazing information about pega Gain the knowledge and hands-on experience you need to successfully design, build and deploy applications with pega. Pega Training in Chennai
ReplyDeleteThanks for sharing amazing information about pega Gain the knowledge and hands-on experience you need to successfully design, build and deploy applications with pega. Pega Training in Chennai
Very nice articles,thanks for sharing
ReplyDeleteSAP Success Factors Training
SAP WebDynpro Training
SCCM 2012 Training
Very good articles,thanks for sharing.
ReplyDeleteSAP HR Abap Training
SAP MM Training
SAP SD Training
Very nice articles,thanks for sharing this useful information.
ReplyDeleteOracle Golden Gate
Ruby On Rails
SAP XI
ReplyDeletehai you have to learned to lot of information about c# .net Gain the knowledge and hands-on experience you need to successfully design, build and deploy applications with c#.net.
C-Net-training-in-chennai
ReplyDeletehai you have to learned to lot of information about c# .net Gain the knowledge and hands-on experience you need to successfully design, build and deploy applications with c#.net.
C-Net-training-in-chennai
Great post and informative blog.it was awesome to read, thanks for sharing this great content to my vision.
ReplyDeletescrum master Training in Chennai
TANGEDCO Recruitment 2016 AE Technical Field Assistant Typist
ReplyDeleteGood post. This is a very clear, informative and helpful post...........
BHEL Bhopal Apprentice Recruitment 2016
ReplyDeletethanks for sharing the useful article very helpful .........
Jharkhand Labour Department Recruitment 2016
ReplyDeleteIt’s amazing how interesting it is, My first visit made me very happy, Thanks to author..............
Really well said about OOP concept in Javajava training in chennai
ReplyDelete