L14-OOP Concepts
L14-OOP Concepts
ELEMENTARY CONCEPT OF
OBJECTS AND CLASSES
STUDY OF OBJECT ORIENTED PROGRAMMING
DEFINITION
It focuses on the process and functions. It focuses on the data and classes.
Due to its complexity, development time Due to easy maintenance, development time
increases. reduces.
Procedural programming languages are not as The object-oriented programming languages are
faster as object-oriented. faster and more effective.
Designs cannot be reused and recycled Designs can be reused throughout the program.
throughout the program.
FEATURES OF OBJECT ORIENTED PROGRAMMING
➢ Object oriented programming (OOP) uses modular
approach in programming.
● Objects
● Classes
● Data Abstraction
● Encapsulation
● Inheritance
● Polymorphism
● Data Handling
CLASSES AND OBJECTS
A class is a user defined blueprint or prototype from
which objects are created. It represents the set of
properties or methods that are common to all
OBJECTS objects of one type.
Behaviour Functions
● Recap
❖ It can't be physical.
A class is a which have common properties.
Difference Between Class & Object
Class Object
● It is a representation of an abstraction
only (not real). ● It is a real and unique entity
having characteristics and
● It is an object producer hence called a
behavior.
blue print or object factory.
● It is created with the help of
● It is a logical identity. ‘new’ operator, called as the
instance of Class.
● Declared with “class” keyword. ● It is physical identity.
● A class is created once. ● Declared with “new” keyword.
● Multiple objects can be created
of a class.
STEPS to Create an Object
● Instantiating a Class - The phrase "instantiating a class" means the same thing as
"creating an object.“
● Here, each object in Class Fruits, is having different characteristics, and some
common
behaviors.
● SYNTAX
● <classname> <objectname> = new <classname>();
● Ex- Fruits Apple = new Fruits ();
● Fruits Banana = new Fruits ();
● It means Apple/Banana is the instance/object of class Fruits.
IMPORTANT TERMS RELATED TO CLASS
Class
Class asas Abstract
User DefinedDataData TypeType
Class as an Object Factory
Object
Each
Class
In programming,
object
asasComposite
Instance
of a class
pre
ofData
defined
ahas
Class
Type built
Class may be used to create
When
common
User
in datacan
we ofcreate
behavior
variousavarious
data
types
or functions
type
is
objects
used
with of
objects of similar types where
athe
which
such
class,
help
as
iseach
of
to
integer,
a
beclass.
object
performed
real,
Itpossesses
character,
mayon contain
the
each object of the class
characteristic
data
stringvalues.
values
etc. isofThe
used.
and
various
data
behavior
Creating
may
types vary
asuch
possesses characteristics (data
defined
from
as
class
string,
object
means
within
integer,
tocreating
the
object
float,
class.but
data
double
Since
thetypes.
etc.
an
members) and behavior (member
object
common
This
Hence is indirectly
why,
a user
operations
a class
may
represents
create
isare
saidcarried
ato
data
a be a
methods) defined within the class.
class
out
‘composite
typeonwith
iteach
is referred
thedata
object
helptype’.
to
of
which
as
a class/This
anis
Hence, class is referred to as an
‘instance
defined
is the reason
within
of a aclass’.
the
class
class.is referred
It is to
‘object factory’.
referred
as ‘user to defined
as ‘abstract
data type.’data type.
Recap
1
Sally is continuing work on her Object-Oriented Program and is
writing code for a car, truck, and bus. These items under the
class called vehicle are referred to as _____.
1.Method
2. Items
3.Attributes
4.Objects
2
1. Sally is writing some Object-Oriented Program code for a vehicle which contains
the attributes (manufacturer, color, and price), along with what she wants the
vehicle to be able to do (start, drive, and park). This is known as a _____.
1.class
2.method
3.function
4.template
3
A _____ is a procedure associated with a class
that describes an action an object is able to
perform.
1.Routine
2. Procedure
3.Functions
4.Method
ABSTRACTION
Bank Details.
ENCAPSULATION