ObjectOrientedProgramming
OOP (Object Oriented Programming)
Java is an object oriented programming language. Programming means the process of writing computer programs. Oriented here means to relate to something. Thus OOP is a way writing programs where everything is related to objects.OBJECT
Object is an identifiable entity with some characteristics and behavior. Entity means something that exists independently. For example Dog is an object which has got some characteristics like age,name,weight, height and behaviors like walking, running, barking, jumping etc. Similarly in Java object too has got characteristics(data) and behaviors(functions).
CHARACTERISTICS OF OOP
1. CLASS
Class is set of objects of same characteristics and behaviors. For example there may be a class of mobile. There can be multiple companies of mobiles each representing an object. Though there are multiple companies yet some characteristics like its screen length, height, cost and behaviors like calling a person, accessing a contact or connecting to WiFi are same always.
2. ABSTRACTION
Abstraction is act of representing essential features without going into background details. It means that the user will only be able to see the necessary features and not every process running in background. For example when we call a person using our phone, we only press the green button to connect to the person. But there are some processes running in background that are not visible to us like trying to connect to the company first and then to the receiving person. This is called abstraction.
3. ENCAPSULATION
Wrapping up of data and functions into a single unit is called Encapsulation. We all are acquainted with the word "Capsule". A powdered medicine or drug is capsuled to protect it from being destroyed, similarly, data and functions are capsuled to protect from unauthorized use. For example a phone stores a number in digital format. But how does it understand and convert it into digital format is hidden from us.
4. POLYMORPHISM
Poly means many and morph means forms. So polymorphism simply means many forms. Sometimes things look the same but have different characteristics depending on situations. For example when you are at school or college, you are a student, at a shop you are a customer and at home you are a boy or girl. So you may have many forms depending on many situations. Similarly in programming language a function may have many forms. For example, when we say draw(). It may mean to draw a circle or rectangle or polygon. This is called polymorphism.
5. INHERITANCE
When we say "inherit" we mean that a child has got some characteristics from its parent. Similarly in programming language, there may be multiple classes and one class may inherit some features of other class. This helps in re-usability of code and also makes our work easier. For example dog, cat, tiger and lion are the child classes of the parent class Animal. Thus these animals inherit some features like legs, tail, mouth, ears etc. Now dog breeds pug,bulldog are the child classes of dog class and they inherit some qualities from dog class like barking.
6. MESSAGE PASSING
In OOP, Message passing means communication between objects by passing messages. In this model objects communicate with each other by passing messages like data packets,signals, functions etc.
There are two types of message passing synchronous and asynchronous. In synchronous message passing sender and receiver wait for each other to communicate and vice versa in asynchronous.
Good job😉
ReplyDeleteBah 👍
ReplyDeleteWonderful...fabulous👏😉
ReplyDeleteDarun!!!!!!!!
ReplyDeleteGood work man..
ReplyDeleteTY
Deletegood work
ReplyDelete