What is Object Oriented Programming?

The ultimate goal of software development is to build a software quickly, correctly and economically. Object Oriented Programming design and implementation approach helps fulfill this goal more productively as compared with structured programming technique. Object oriented programs are often easier to understand, correct and modify.

In object oriented programming we divide or organize our program using classes, objects and methods. We will discuss some object oriented programming concepts below.

Objects and Classes:

A class is a collection of similar attributes (also known as members or variables) and methods (also known as actions or functions) in object oriented programming. All objects belonging to a particular class will share the attributes and methods of that class. For example a class that represents a bank account might contain attributes like account holder’s name, account number and account balance.

Performing a task in a program requires a method (or function). The method contains the program statements that actually perform its tasks. In Object Oriented Programming, we create a program unit called a class to contain the set of methods that perform tasks of the class. For example, a class that represents a bank account might contain one method to deposit money to an account, another to withdraw money from an account and a third to inquire what the account’s current balance is.

Instantiation:

In order to use the capabilities (attributes and methods) of any particular class we need to create an object of that class. This process is called instantiation.  An object is then referred to as an instance of its class.

Reuse:

Once a class is created we can use/reuse that class to create any number of objects (instances) of that class. For example if we have a class that represents customers. Then we can create many instances of customers e.g customer 1, customer 2, customer 3 etc. by using that class.

Encapsulation:

Classes encapsulate (i.e., wrap) attributes and methods into objects. Objects may communicate with one another, but
they’re normally not allowed to know how other objects are implemented—implementation details are
hidden within the objects themselves. This process of information hiding is known as encapsulation.

Inheritance:

A class (child class) can inherit some attributes and methods from an existing class (parent class). This process is known as inheritance.  The new class absorbs the characteristics of an existing class, possibly customizing them and adding unique characteristics of its own.

 

Resources:

Java How to Program by Paul Dietel and Harvey Dietel chapter #01

Leave a Comment