introduction to
OBJECT ORIENTED PROGRAMMING
our Objectives are:
• to Define Object Oriented Programming
• to Understand the Terminologies and
Concepts of OOP
OOP
stands for Object Oriented Programming
Definition
• OOP is a method of programming
based on a hierarchy of classes, and
well-defined and cooperating objects
Definition
• OOP is a programming style that
encourages modularization and
restricted data access
Definition
• OOP is a process of creating programs
and then linking them together to
accomplish a task or solve a problem
Advantages of OOP
• OOP provides a clear modular
structure for programs which makes it
good for defining abstract data types
where implementation details are
hidden and the unit has a clearly
defined interface.
Advantages of OOP
• OOP makes it easy to maintain and
modify existing code as new objects
can be created with small differences
to existing ones.
Advantages of OOP
• OOP provides a good framework for
code libraries where supplied software
components can be easily adapted and
modified by the programmer.
• This is particularly useful for
developing graphical user interfaces.
Advantages of OOP
Faster Development – it requires less
code and time in program development
Increase Quality – it enhance program
modularity and reusability
Enhance Modifiability - easy to update
Maintenance easier – easy to maintain
OOP Terminologies and
Concepts
Object
The basic run-time entities in an
object-oriented program.
Object
• Programming problem is analyzed in
terms of objects and nature of
communication between them. When a
program is executed, objects interact
with each other by sending messages.
Object is an entity that has a state,
behavior and identity with a well-defined
role in problem space
example: A person
A person have status, action and
information
Attributes
- Parts of the object
- Information about the object
to be continued…
introduction to
OBJECT ORIENTED PROGRAMMING
Class
A collection of objects of similar
type
Package
It is a Group of classes and it is
analogous to a directory
4 Data Access Levels
Public
Private
Protected
Package
Data Access Levels
• Classes, and their fields and methods
have access levels to specify how they
can be used by other objects during
execution, while cooperation among
objects is desirable, there are times
when you will want to explicitly control
access, and specifying access levels is
the way to gain that control.
Data Access Levels
• Fields and methods can be declared
private, protected, public, or package.
• If no access level is specified, the field
or method access level is package by
default.
Data Access Levels
• Private : object is accessible only to
the class in which it is defined
• Public : object is accessible to any
class of any parentage in any package
Data Access Levels
• Protected : object is accessible to the
class itself and other classes in the
same package.
• Package : object is accessible to other
class in the same package
Method
A group of procedures that manipulate data
Data Abstraction
The act of representing essential
features without including the background
details or explanations. Simply, get only
what is important.
Encapsulation
It allows objects to hide from other
object and outside contamination
Inheritance
The process by which objects can
acquire the properties of other objects
In OOP, inheritance provides
reusability, like, adding additional
features to an existing class without
modifying it.
Inheritance
Polymorphism
The ability to take more than one
form
In OOP, polymorphism provides
flexibility because of objects can
change its form
Polymorphism
• means “many forms but at one”, the
same set of instructions can be use for
many different objects because it
represents a common activity.
• An ability of an object to assume many
different forms.
Polymorphism
Instantiation
A new occurrence of object, defining
instance of an object is called
instantiation.
ex: Object X = new Object;
Student pedro = new Student;
Instantiation
Modularization
END OF THE SLIDES