View stunning SlideShares in full-screen with the new iOS app!Introducing SlideShare for AndroidExplore all your favorite topics in the SlideShare appGet the SlideShare app to Save for Later — even offline
View stunning SlideShares in full-screen with the new Android app!View stunning SlideShares in full-screen with the new iOS app!
OBJECT ORIENTED PROGRAMMING
Amanda Rosa Blanca R. Arevalo
BSIT – 201P
13 November 2012
Define what is OOP (Object Oriented Programming)
Object Oriented Programming (OOP) is a type of programming in which programmers define
not only the data type of a data structure, but also the types of operations (functions) that
can be applied to the data structure. In this way, the data structure becomes an object that
includes both data and functions. In addition, programmers can create relationships
between one object and another. For example, objects can inherit characteristics from
An object-oriented program may be viewed as a collection of interacting objects, as opposed to
the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In
OOP, each object is capable of receiving messages, processing data, and sending messages to
other objects. Each object can be viewed as an independent machine with a distinct role or
responsibility. The actions or methods on these objects are closely associated with the object.
For example, OOP data structures tend to carry their own operators around with them or at
least inherit them from a similar object or class) - except when they have to be serialized.
One of the principal advantages of object-oriented programming techniques over procedural
programming techniques is that they enable programmers to create modules that do not need
to be changed when a new type of object is added. A programmer can simply create a new
object that inherits many of its features from existing objects. This makes object-oriented
programs easier to modify.
To perform object-oriented programming, one needs an object-oriented programming
language (OOPL). Java, C++ and Smalltalk are three of the more popular languages.
Describe each concept of OOP.
An object can be considered a "thing" that can perform a set of related
activities. The set of activities that the object performs defines the object's behavior. For
example, the hand can grip something or a Student (object) can give the name or
Objects are the fundamental building blocks of applications from an objectoriented perspective. Objects of many different types are use in developing
applications. Each different type of object comes from a specific class of that type.
OBJECT ORIENTED PROGRAMMING
An object is a self-contained component that contains properties and methods
needed to make a certain type of data useful. An object’s properties are what it knows
and its methods are what it can do.
In addition to providing the functionality of the application, methods ensure
that an object’s data is used appropriately by running checks for the specific type of
data being used. They also allow for the actual implementation of tasks to be hidden
and for particular operations to be standardized across different types of objects.
A class is a blueprint or template or a set of instructions to build a specific type
of object. Every object is built from a class. Each class is designed and programmed to
accomplish one, and only one, thing. Because each class is designed to have only a single
responsibility, many classes are used to build an entire application.
A class is simply a representation of a type of object. It is the blueprint/ plan/
template that describe the details of an object. A class is the blueprint from which the
individual objects are created. Class is composed of three things: a name, attributes, and
An instance is an occurrence or a copy of an object, whether currently executing
or not. Instances of a class share the same set of attributes, yet will typically differ in
what those attributes contain. For example, a class "Employee" would describe the
attributes common to all instances of the Employee class.
A method is a subroutine or procedure associated with a class. Methods define
the behavior to be exhibited by instances of the associated class at program run time.
Methods have the special property that at runtime, they have access to data stored in
an instance of the class (or class instance or class object or object) they are associated
with and are thereby able to control the state of the instance. The association between
class and method is called binding. A method associated with a class is said to
be bound to the class. Methods can be bound to a class at compile time, called static
binding or to an object at runtime known as dynamic binding.
OBJECT ORIENTED PROGRAMMING
Ability of a new class to be created, from an existing class by extending it, is
Inheritance enables new objects to take on the properties of existing objects. A
class that is used as the basis for inheritance is called a superclass or base class. A class
that inherits from a superclass is called a subclass or derived class. For example, a child
inherits visible properties and methods from its parent while adding additional
properties and methods of its own.
An interface is a collection of method declarations that allows unrelated objects
to communicate with one another.
Methods form the object's interface with the outside world. For example, the
buttons on the front of your television set are the interface between you and the
electrical wiring on the other side of its plastic casing. You press the "power" button to
turn the television on and off.
Encapsulation is the inclusion, within a program object, of all the resources need for
the object to function within a program object, such as the methods and the data
When we create an object in an object-oriented language, we can hide the
complexity of the internal workings of the object. As a developer, there are two main
reasons why you would choose to hide complexity.
The first reason is to provide a simplified and understandable way to use your
object without the need to understand the complexity inside. For example, a driver
doesn't need to know how an internal combustion engine works. It is sufficient to know
how to start the car, how to engage the transmission if you want to move, how to
provide fuel, how to stop the car, and how to turn off the engine.
Hiding the complexity of the car from the user allows anyone, not just a
mechanic, to drive a car. In the same way, hiding the complex functionality of your
object from the user allows anyone to use it and to find ways to reuse it in the future
regardless of their knowledge of the internal workings. This concept of keeping
implementation details hidden from the rest of the system is key to object-oriented
The second reason for hiding complexity is to manage change. Today most of us
who drive use a vehicle with a gasoline-powered internal combustion engine. However,
OBJECT ORIENTED PROGRAMMING
there a gas-electric hybrids, pure electric motors, and a variety of internal combustion
engines that use alternative fuels. Each of those engine types has a different internal
mechanism yet we are able to drive each of them because that complexity has been
hidden. This means that, even though the mechanism which propels the car changes,
the system itself functions the same way from the user's perspective.
Message passing is a form of communication used in object-oriented programming. In
this model, processes or objects can send and receive messages (comprising zero or more bytes,
complex data structures, or even segments of code) to other processes. By waiting for
messages, processes can also synchronize.
Abstraction is the process by which data and programs are defined with
a representation similar in form to its meaning (semantics), while hiding away
the implementation details. Abstraction tries to reduce and factor out details so that
the programmer can focus on a few concepts at a time. It captures only those details
about an object that are relevant to the current perspective.
Polymorphism is the concept that multiple types of objects might be able to work in a
given situation. For example, if you needed to write a message on a piece of paper, you could
use a pen, pencil, marker or even a crayon. You only require that the item you use can fit in your
hand and can make a mark when pressed against the paper.
A package is a namespace for organizing classes and interfaces in a logical manner.
Placing your code into packages makes large software projects easier to manage.