Paper Outlining the Various Concepts Found in Object Oriented Programming (OOP)

Paper Outlining the Various Concepts Found in Object Oriented Programming (OOP)


The following paper outlines the various concepts found in Object Oriented Programming (OOP). Applications created through OOP are generally easier to maintain, consist of more reusable components, as well as being more scalable, robust, and reliable. The following information will describe the various facets of Object Oriented Programming and how each of these items contributes to the object oriented paradigm.
Objects (instances)

Objects are at the core of Object-Oriented development and technology. The concept is that all objects have two characteristics: state and behavior (Oracle, 2011). The state of an object is stored through the object’s fields or variables. An object’s possible states depend on the purpose of the object. For example: if the object decides what environment the program is running in the possible states could be “UAT” or “Production.” An object’s behavior is simply what the object can do or the processes for which the object was created. These processes are access through the object’s methods.

Objects are the instances of a specific class definition. In other words, once a class is defined (given properties and methods) an object can be created based on that class’s template and then used by the program. With an object, a class is just a prototype unable to be used by the program (JR's Educational Pages, 2009).

The below example (Oracle, 2011) creates two bicycle objects:
class BicycleDemo {
public static void main(String[] args) {
// Create two different Bicycle objects
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
// Invoke methods on those objects
Instance Variables (Attributes or Properties)
Instance Variable is class variable technically speaking instance variables are object store in individual states with Non-static variables unique class things and object know.
Attributes or Properties they have command types that have properties that need to be configured every property that new instance specified
Property Attributes or properties can have that interface that can identifies different commands and properties attributes you have menu path and different fields
In object-oriented development, methods (or functions) are what controls and exposes an object’s behavior. They are the processes for which the object was created (steves tutes, 2010). Through data encapsulation, an object’s methods become the primary communication tools between other objects.
Because methods are the processes that objects carry out, they are where the real “code” for object-oriented programs lies. Methods can do anything from simple or complex calculations to interact with other systems. In the below example the calculateMortgagePayment returns the monthly mortgage payment calculated from the loan amount, interest rate and term passed to the function.
static double calculateMortgagePayment(double loanAmount, double interest, double amort) {
return loanAmount * (interest/(1-(Math.pow(1+interest,-amort))));
Message: Are information compiler operation they are syntax and they are commands designed to collect personal information.
In java an interface is defined in much the same way. A number of method signatures, nested types, and constants may be grouped together with each other to define the behavior of an object. This grouping of descriptive of method signatures, nested types, and constants would have empty bodies and be known as a as an interface. Such a grouping might contain instructions for how a virtual keyboard should work. This interface would be named “keyboard”. Then when the programmer decides to utilize the interface, therefore applying the preset scripts to the program, they would set their class and implement the interface.
By utilizing an interface a programmer is able to better define the way a class will behave. This is helpful to a programmer as it ensures that the program will have continuity to the method signatures, nested types, and constants of which an interface encapsulates. It becomes unnecessary to program in the interface every time that the program would call on it, instead the interface has a title which is called on thereby eliminating any chance that the code could be mistyped if used multiple times throughout a program.
Below is a brief example of an interface involving dogs:
public interface Dog extends Animal {
public String ownerName;
public String breed;
public String furColor;
public String eyeColor;
public void bark();
public void bite(Person badPerson);
public void lick(Person nicePerson);
public void chase(Cat cat);
public void walk(int xPosition, int yPosition);
A program may rely on a number of different pieces of code developed by just as many developers, and at times it may become necessary for one of those developers to make a change to their code. In order to protect these different pieces from being tampered with or changed these developers will most likely encapsulate their code. Encapsulation is the method in which a programmer can make certain fields in a class private, thereby denying access to anything outside the class, and is one of the four fundamental principles of object oriented programming. This obfuscating encapsulation is sometimes known as data hiding.
Data hiding insulates objects from eternal access. In the past languages did not have this feature. Programs could find their contents being altered or recycled in unexpected ways. This changing lead to code that was hard to understand and near impossible to unravel. Now code is protected from such intentional or unintentional changes and is able to be kept more orderly.
Below is an example of encapsulation which encapsulates the volume of a box and packing items in it:
public class Box {
private float length;
private float width;
private float height;
private String[] contents;
private int index = 0;
Box() {
contents = new String[10];
public void setLength(float length) {
this.length = length ;
public void setWidth(float width) {
this.width = width;
public void setHeight(float height) {
this.height = height;
public void insert(String item) {
contents[index] = item;
public float getVolume() {
return length*width*height;
An important feature of Object Oriented Programming is the ability to create a new class based on an existing class that has already been defined, whether by the programmer, Java , or by another programmer. Different kinds of objects often have a relationship that has certain attributes in common with each other. Adults and Children for example, both share the attributes of being a person such as having a name, age, sex etc. Yet each has unique properties that the other does not. For example, children have weekly allowances while adults have jobs.
The common features the two objects share can be represented in a base class called Person, from which each object could be derived. The inclusion of a base class' members within a derived class (so that they are accessible) is called class inheritance.
The subclass is said to have an "is-a" relationship with its base class. For example, an Adult "is-a" person, and therefore shares the same basic attributes of any person object. Instead of writing the same common fields and methods for both an Adult and Child class, one only needs to define a base class called Person from which both classes will inherit these shared attributes. A new class can be derived from an existing class using the extends keyword, for example: class SubClassName Extends SuperClassName{}.
One main benefit of inheritance is code reusability. The new class can reuse the fields and methods of the existing class so that the programmer does not need to write the extra code, thus cutting down on duplicity as well as saving time and effort.
The generic example below illustrates inheritance by extending the class Person to create the subclass Child; which "is-a" Person. The subclass Child is a derivation of the base class Person and will inherit the state and behavior of the Person class, but it will also contain its own fields and methods that are specific to the Child class, such as including an allowance field and methods.
Basic Code Example: Inheritance

class Person {
String personsName;
int PersonsAge;
String personsSex;
// The Constructor
public Person (String personsName, int personsAge, String personsSex) {
this.personsName = personsName;
this.personsAge = personsAge;
this.personsSex = personsSex
// "setter methods"
public void setPersonsName (String personsName) {
this.personsName = personsName;
public void setPersonsAge (String personsAge) {
this.personsAge = personsAge;
public void setPersonsSex (String personsSex) {
this.personsSex = personsSex;
// "getter methods"
public String getPersonsName () {
return personsName;
public String getPersonsAge () {
return personsAge;
public String getPersonsSex () {
return personsSex;
} // end class
class Child extends Person {
double allowance;
public Child(String personsName, int personsAge, String personsSex) {
super(personsName, personsAge, personsSex);
public void setAllowance (String a) {
allowance = a;
public double getAllowance() {
return allowance;
In Object Oriented Programming (OOP) Polymorphism allows objects to take on the reference variables that other objects are defined with. However this can only take place if the reference variable is declared as a class or interface type (Tutorials point .com., 2011).
public interface Vegetarian { }
public class Animal { }
pubic class Deer extends Animal implements Vegetarian { }
Now the Deer is an Animal, Vegetarian, a Deer and an Object. The Deer class is now considered to be of multiple inheritance and polymorphic. Because the Deer class is of multiple inheritance the reference variables of the other classes are equal to the Deer class (Tutorials point .com., 2011).
Polymorphism allows a subclass to take on the traits of its super class but the subclass is still somewhat unique. If you had a class Bicycle and added a class like MountainBike that extends Bicycle it allows the MountainBike subclass to take on the characteristics of the super class Bicycle. This does not change the super class Bicycle however. The reference variables in the class Bicycle will remain the same just as the reference variables in MountainBike will remain the same but when MountainBike becomes a subclass to Bicycle It allows MountainBike to be polymorphic because it takes on the characteristics of both the super class Bicycle and its own reference variables. Another class could be added to Bicycle like RoadBike. RoadBike would take on the reference variables of Bicycle but not the reference variables of MountainBike (Oracle, 2011).
Objects, instance variables, methods, messages, interfaces, encapsulation, inheritance and polymorphism are all terms used in object oriented programming. The examples of these terms provide a basic understanding of how these terms would look in Java code and how they are used. Each of the terms may not be used in every program or application created by programmers. It is up to the programmers to decide when, how and if they will use each of these terms in the code they write.

JR's Educational Pages. (2009). Java tutorial 1. Retrieved from
Oracle. (2011). The Java Tutorials. Retrieved from
Oracle. (2011). What is an object?. Retrieved from
Oracle. (2011). Inheritance. Retrieved from
Steves tutes. (2010). java methods. Retrieved from
Tutorials point .com. (2011). Tutorials point .com. Retrieved from