Hi Guy’s Welcome to Proto Coders Point. This Article is on basic quick revision oops concepts of java that can be asked in interview.
Object Oriented Programming System(OOPs)
If we take real world example, a Object are pen, table, personal computer… etc. In JAVA Programming OOPs is a methodology used to design programs using classes & objects. By using object oriented we can make software development simple. Here are the OOPS Concepts:
Quickly Revise OOPS Concepts
- Object.
- Class.
- Inheritance.
- Encapsulation.
- Abstraction.
- Polymorphism.
Here inheritance, encapsulation, abstraction, & polymorphism are called as four pillars of JAVA Programming language.
1. Object
Any real world entity is an Object. It has Behavior and Attribute. Here:
Behavior can be defined as what an object does and what is can perform.
Attribute is used to describe a Object.
Here is a small example:
Chair: In Real word a chair is an object, which has behaviour feature like wheem movement, Height and recline adjectment. and chair’s attribute like it’s color, number of wheels, max height adjuctment, price etc.
2. Class
The collection of all related object is called as class, Consider general category as a class, which contains related objects within it.
Example: Chair
Object like Office Chair, Wheel chair, recliner chair, gaming chai etc all this below to one class that is Chair class.
3. Inheritance
To Understand Inheritance concept in java, let’s take real world eg: In child aquire the qualities from his/her parent. Similarly, a Child class can also inherit feature from it’s parent class.
Basically Inheritance is a machanism by which one class (child) can aquire all the properties/features of another class(parent).
Example: Phone
Parent class Phone can have two child classes -:
- TelePhone
- MobilePhone
Both of this child classes has inherited a calling feature behaviour.
4. Encapsulation
In Java Encapsulation means wrapping up of data into a single unit & securing it, By encapsulation process data will get secured from outside words.
Example:
Bank Locker: You create a bank locker where you keep all your valuable thinks lets say the locker as (single unit) and then you protect the locker using a key or digital passcode.
Medicine Capsules: It has a wraps from outside and all the medicine ingredient is wraps into that capsules for protecting it from outsite atmosphere.
5. Abstraction
The Inside working machanism is been hidden from the user, and the user can only be able to user those feature, which him/her know how the machanism actual works.
This helps the user to be focus on product usage.
Eg:
Car: A Car, is full of complexity machanism like engine, gear box. User no need to know in depth about this. Only the relevent part is shown like brakes, accelerator, gear’s how to use it.
6. Polymorphism
The word polymorphism means many forms, The meaning of polymorphism means same name can we used for different behavious.
Eg: Chess: All chess pieces like king, bishop, knight, rook … etc move in different directions, Bishop moves diagnallym Rooks move horizontal and verticle etc.
The common behaviour in chess game is “move”, but the different over here is direction.
Conclusion
This article is basic revise of Java OOPS Concepts, We can use OOP Concepts to map any real-world solutions into programming very easily.
That’s why OOP concept is designed close to real world.
A Better understanding of these concepts is going to decide how good programmers we will become in future. Have a look at Dart programming OOPS Concepts