3. Definition
⚫ Object-oriented programming (OOP) is a
programming paradigm using "objects" – data
structures consisting of data fields and methods
together with their interactions – to design
applicationsand computerprograms. Programming
techniques may include features such as data
abstraction, encapsulation, messaging, modularity,
polymorphism, and inheritance
5. Abstraction
⚫ Abstraction (from the Latin abs, meaning away from
and traction meaning to draw) is the process of taking
away or removing characteristics from something in
order toreduce it toa setof essential characteristics. In
object-oriented programming, abstraction is one of
three central principles (along with encapsulation and
inheritance). Through the process of abstraction, a
programmer hides all but the relevant data about an
object in order to reduce complexity and increase
efficiency. In the sameway thatabstractionomitted
6. Polymorphism
⚫ polymorphism refers toa programming language's
ability to process objects differently depending on
their data type or class. More specifically, it is the
ability to redefine methods for derived classes. For
example, given a base class shape, polymorphism
enables the programmer todefinedifferent area
methods for any number of derived classes, such as
circles, rectangles and triangles. No matterwhatshape
an object is, applying the area method to it will return
thecorrect results. Polymorphism isconsidered to be a
requirement of any true object-oriented programming
language (OOPL).
7. Inheritance
⚫ In object-oriented programming (OOP), inheritance
is a way to compartmentalize and reuse code by
creating collectionsof attributesand behaviorscalled
objects that can be based on previously created
objects. In classical inheritance where objects are
defined byclasses, classescan inheritotherclasses.
The new classes, known as subclasses (or derived
classes), inheritattributesand behavior (i.e. previously
coded algorithms) of the pre-existing classes, which
are referred to as superclasses, ancestor classes or base
classes. The inheritance relationships of classes gives
rise toa hierarchy
8. Encapsulation
⚫Encapsulation means as much as shielding. Each
object-oriented object has a shield around it. Objects
can't 'see' each other. They can exchange things
though, as if theyare interconnected through a hatch.
⚫shows theconceptof theencapsulation. Itseparates
the external aspects of an object from the internal
implementation details of the object, which are
hidden from other objects. The object encapsulates
both data and the logical procedures required to
manipulate thedata.
10. Classes
⚫ In object-oriented programming, a class is a construct
that is used as a blueprint to create instances of itself –
referred to as class instances, class objects, instance
objects or simply objects. A class defines constituent
members which enable these class instances to have
state and behavior. Data field members (member
variables or instance variables) enable a class object to
maintain state. Other kinds of members, especially
methods, enable a class object's behavior
11. Class In Java
⚫ Classesare the fundamental building blocksof a Java
program. Youcan define an Employeeclassas follows:
⚫class Employee {
int age;
double salary;
}
⚫Byconvention, class namescapitalize the initial of
each word.
⚫Forexample: Employee, Boss, DateUtility, PostOffice,
RegularRateCalculator.
12. Continued
⚫This typeof naming convention is knownas Pascal
naming convention.
⚫The otherconvention, thecamel naming convention,
capitalize the initial of each word, except the first
word.
⚫Method and field names use thecamel naming
convention
13. Object
⚫ An object doesn't exist until an instance of the class
has been created; the class is just a definition. When
theobject is physicallycreated, space for thatobject is
allocated in RAM. It is possible to have multiple
objectscreated from oneclass.
14. Access Control
In Javathere are 4 typesof access types
⚫1. Private .
⚫2. public .
⚫3. default (no type )
⚫4. protected .