OOPS-Concepts
|
Object Oriented Programming Concepts
Classes, Objects, and Methods are the most basic concepts for object
oriented programming. Besides, Inheritance, Abstraction, Polymorphism, Event
and Encapsulation are the other concepts that OOPs features. Object: An Object is a computer
representation of some real-world thing (i.e person, place) or event. Objects
can have both attributes and behaviours
Class: A class is a blueprint or prototype from which objects are created.
This section defines a class that models the state and behaviour of a
real-world object. It intentionally focuses on the basics, showing how even a
simple class can cleanly model state and behaviour. Inheritance: Inheritance provides a powerful and natural mechanism for organizing
and structuring your software. This section explains how classes inherit
state and behaviour from their superclasses, and explains how to derive one
class from another using the simple syntax provided by the Java programming
language. Encapsulation: Encapsulation (or information hiding) is a principle, about hiding the
details of the implementation of the interface. It is to reveal as little as
possible about the inner workings of the Interface. Polymorphism: Polymorphism allows the
programmer to treat derived class members just like their parent class'
members. More precisely, Polymorphism in object-oriented programming is the
ability of objects belonging to different data types to respond to method
calls of methods of the same name, each one according to an appropriate
type-specific behaviour. One method, or an operator such as +, -, or *, can
be abstractly applied in many different situations Abstraction: Abstraction refers to the act of representing essential features
without including the background details or explanations. Classes use the
concept of abstraction and are defined as a list of abstract attributes. encapsulation: Storing data and functions in a single unit (class) is encapsulation.
Data cannot be accessible to the outside world and only those functions which
are stored in the class can access it. A major factor in the invention of Object-Oriented approach is to
remove some of the flaws encountered with the procedural approach. In OOP,
data is treated as a critical element and does not allow it to flow freely.
It bounds data closely to the functions that operate on it and protects it
from accidental modification from outside functions. OOP allows decomposition
of a problem into a number of entities called objects and then builds data
and functions around these objects. A
major advantage of OOP is code reusability. |