- Object Oriented Programming or OOP is the technique to create programs based on the real world.
- Unlike procedural programming, here in the OOP programming model programs are organized around objects and data rather than actions and logic.
- In OOP based language the principal aim is to find out the objects to manipulate and their relation between each other.
- Another important work in OOP is to classify objects into different types according to their properties and behavior.
What Is an Object?
- An object is a software bundle of related state and behavior.
- Objects are the basic unit of object orientation with behavior, identity.
- Objects in programming language have certain behavior, properties, type, and identity.
- An object is expressed by the variable and methods within the objects.
- Again these variables and methods are distinguished from each other as instant variables, instant methods and class variable and class methods.
- Attributes are defined by variables and Behaviors are represented by methods
What Is a Class?
- A class is a blueprint or prototype from which objects are created.
- It is the central point of OOP and that contains data and codes with behavior.
- In Java everything happens within class and it describes a set of objects with common behavior.
- The class definition describes all the properties, behavior, and identity of objects present within that class.
What Is Inheritance?
- Inheritance provides a powerful and natural mechanism for organizing and structuring your software.
- classes inherit state and behavior from their superclasses, ie. derive one class from another
- This is the mechanism of organizing and structuring software program.
- Though objects are distinguished from each other by some additional features but there are objects that share certain things common.
- In object oriented programming classes can inherit some common behavior and state from others.
- Inheritance in OOP allows to define a general class and later to organize some other classes simply adding some details with the old class definition.
- This helps in a better data analysis, accurate coding and reduces development time.
Abstraction -
- The process of abstraction in Java is used to hide certain details and only show the essential features of the object. In other words, it deals with the outside view of an object (interface).
- It refers to the act of representing essential features without including the background details.
- for example:If a customer wants to buy a car.he looks at its color,perfomance etc but he doesnt look at things like how these are functioning internally etc.
- The technique of choosing common features of objects and methods is known as abstracting. It also involves with concealing the details and highlighting only the essential features of a particular object or a concept. A Java programmer makes use of abstraction to specify that a couple of functions form the same kind of task and can be merged to perform a single function.
- Abstraction along with two other techniques, information hiding and encapsulation are the most significant techniques in software engineering. All of these three functionalities are known to reduce complexities in processing and programming.
Encapsulation -
- This is an important programming concept that assists in separating an object's state from its behavior. This helps in hiding an object's data describing its state from any further modification by external component.
- In Java there are four different terms used for hiding data constructs and these are public, private, protected and package.
- As we know an object can associated with data with predefined classes and in any application an object can know about the data it needs to know about. So any unnecessary data are not required by an object can be hidden by this process.
- It can also be termed as information hiding that prohibits outsiders in seeing the inside of an object in which abstraction is implemented.
- Abstraction means implementation hiding and Encapsulation means data hiding.
Polymorphism -
- It describes the ability of the object in belonging to different types with specific behavior of each type.
- So by using this, one object can be treated like another and in this way it can create and define multiple level of interface.
- Here the programmers need not have to know the exact type of object in advance and this is being implemented at runtime.
1.Compile-time polymorphism:
what object will be assigned to the present variable.
This will be evaluated at compile time.
2.Run-time polymorphism:
what object will be assigned to the present variable.
This will be evaluated at runtime depending on condition.
what are the oops concept in java explain with real time examples?
OOPS Concepts are mainly 4
1.Abstraction
2.Encapsulation
3.Inheritance/Delegation
4.Polymorphism
Abstraction:-Hiding non-essential features and showing the
essential features
(or)
Hiding unnecessary data from the users details,is called
abstraction.
Real Time example:TV Remote Button
in that number format and power buttons and other buttons
there.just we are seeing the butttons,we don't see the
button circuits.i.e buttons circutes and wirings all are
hidden.so i think its good example.
Encapsulation:
Writing Operations and methods stored in a single
class.This is Called Encapsulation
Real Time Example:Medical Capsule
i.e one drug is stored in bottom layer and another drug is
stored in Upper layer these two layers are combined in
single capsule.
Inheritance:
The New Class is Existing from Old Class,i.e SubClass is
Existing from Super Class.
Real Time Example: Father and Son Relationship
Polymorphism:
Single Form behaving differently in different Situations.
Example:- Person
Person in Home act is husband/son,
in Office acts Employer.
in Public Good Citizen.
what actually is the difference between Encapsulation & Data hiding & Data Abstraction
Data hiding is just a means by which one hides away data from the
external world... example, the lungs of a person is not seen by anyone,
but used for the internal working of the human being!
Data Encapsulation allows to package all the contents of the object.
They may or may not be public to the external world. Example, the skin
is part of the human, and so is the lung. Together all the components
of the human make up one whole being!
Data Abstraction is the means by which one displays only
what is required to the user. Sample - the mood of a person to a girl,
a snake, a cat, a father, or a boss. Though they are all emotions, they
differ based on the stimuli, and hence a portion of the whole is
displayed to the person who requests it.
No comments:
Post a Comment