Object Oriented Design and Programming



Object-Oriented Programming (OOP) is used to describe a programming approach that supported objects and categories. Object-Oriented Programming is extremely useful for “beginner programmers” and sometimes for intermediates. Object-oriented programming (OOP) may be a programming paradigm supported the thought of “objects”, which may contain data and code: data within the form of fields (often referred to as attributes or properties), and code, within the form of procedures. The object-oriented programming approach encourages:


  • Modularization: It is a method where the application can be decomposed into modules.
  • Software re-use: Here an application can be composed from existing and new modules.



Since the Eighties, the word ‘object’ has made its appearance bearing the relevance in the field of programming languages. Most languages developed since 1990 having object-oriented options. Learning object-oriented programming is crucial to any or all trendy packages’ development—including mobile apps. It will safely be aforesaid that the item has been the propulsion within the programming business for an awfully very long time and can still be thus for the predictable future. As a result, nearly all programming languages, scripting languages, and application styles area units are object-oriented or object-based. It is widely accepted that object-oriented programming is the most significant and powerful means of making software package.


The Highlighted Topics are Discussed Below



  • Computer systems.
  • Simple program logic.
  • The steps involved in the program development cycle.
  • Pseudocode statements and flowchart symbols.
  • Using a Sentinel value to end a program.
  • Programming and user environment.
  • The evolution of programming models.




A computer system is a combination of all the components required to process and store data. A computer system is composed of hardware and software. Software is classified into two types, application software, and system software. (Farrell, J. 2017).

Hardware and software contain input, processing, and output. The major computer programming languages are VB, C#, Java, C++. Compiler or software translates the source code to machine language statements. And is machine language statement is called object code.

Syntax error in the Program is called syntactical error and a logic error in a program is called logical error.

Two most common planning tools are flowcharts and pseudocode.

  • Flowchart: A flowchart is a pictorial representation of logical steps it takes to solve a problem.


  • Pseudocode: It is a representation in the English language of the logical steps it takes to solve a problem.


Repeating or looping concepts in a program helps to execute one or more statements up to a desired number of times.


  • Text editor and IDE are used for programming environments.
  • Command-line and GUI are used for user environments.


The Highlighted Topics are Discussed Below



  •  Declaring and using variables.
  •  Data types.
  •  Arithmetic operators.
  • Declaring and using constants
  • Using a Sentinel value to end a program.
  • JAVA basics.
  • I/O.



A ‘variable declaration’ gives assurance to the compiler that the existence of the variable. The data type defines that operations will safely be performed to create, transform, and use the variable in another computation. Here we can mention some of the data types like-

  • int
  • float
  • double
  • char

Variables are case sensitive and naming conventions are Camel casing, Pascal casing, Hungarian notation, Snake casing, Mixed case without underscores, Kebob case.

Different arithmetic operators can be used + (addition), – (subtraction), * (multiplication), / (division) in program code.

Two types of constants are used in code, ‘Numeric Constant’ and ‘String Constant’.


Numeric Constant Number (ex: 1,2,3,4,5 etc)
String Constant Number and character (ex: 1,2,3,4 and A, B, C, D etc)


Introduction of Java:

  • Java is an Object-oriented programming language.
  • Java is based on object and class.
  • Java is platform dependent.

I/O is used to perform input and output operations. Input expect from the user and output is the value that returns to the user.


Input example:

int nextInt(int n);

Output example:

System.out.println(“Next int value: “+number+”\n”);


The Highlighted Topics are Discussed Below



  • Disadvantage of unstructured spaghetti code.
  • Three basic structures- sequence, selection and loop.
  • Need for structure.
  • Recognizing structure.



The descriptive name for logically snarled program statement is spaghetti code.

Disadvantages of unstructured spaghetti code:

  • Spaghetti code cannot produce correct results.
  • Spaghetti code more difficult to maintain than other programs.


A structure is based on program logic. Each structure program consists of sequence, selection, and loop. Any structured program contains any number of structures (Budd, T. 2008).


  • Sequence: Performs action or tasks.
  • Selection: Is used to perform in decision making. In selection structure ‘if-then-else’is used.
  • Loop: Loop implies repeat actions.


Selection structure use different relational operators as follows-

== Equivalency
> Greater than
< Less than
>= Greater than equal to
<= Less than equal to
!= Not equal to
&& Logical AND
|| Logical OR
| Logical NOT


Below is the syntax of case structure in Java

switch(expression) {

case value :

break; // optional

case value :

break; // optional

default : // Optional



The Highlighted Topics are Discussed Below



  • While loop.
  • Do-while loop.
  • For loop.
  • Combination of programming structures.
  • Understanding the reasons for structure.



Loop is a control variable and which is defined for the transformer stage. Loop condition determines whether the program will run or break. It repeats a set of actions while a condition remains true. There are three different loop conditions such as ‘while loop’, ‘Do-while’, and ‘for loop’ (Farrell, J. 2017).

While loop: It evaluates the statement within the parenthesis. If the process-condition evaluates false, the loop terminates.


while (condition) {

// body of the loop


Do-while loop: It is similar to while loop. Do-while loop is called ‘post-test loop’, because the condition is tested after the loop’s body has executed.


do {


} while (condition);

For loop:This loop is a repetition management structure that permits expeditiously to write a loop that has to execute a particular range of times.


for ( init; condition; increment ) {



Statement endif, if-then-else, endwhile is end structure statement.

Structure-programming is used for clarity, professionalism, efficiency, maintenance, and modularity.


The Highlighted Topics are Discussed Below




  • Array- one dimensional and two dimensional
  • Declaration, creation and initialization
  • Basic operations



Array is a collection of data elements. There are two types of data arrays- single dimensional array and multi-dimensional array. Single dimensional array stores data in a linear form and multi-dimensional array, having more than one dimension, stores data in tabular format. (Kiong, D., Ashok, S.,& Poo, D. 2008).

Single Dimensional Array: Example: intArray[0] = 1;

Multi Dimensional Array: Example: int a[] [][]= new int[2][3][4];

Advantages of array:

  1. Saving memory
  2. Cache friendly
  3. Easier debugging


Array in a java program involves three distinct steps.

  1. Declare the array


<elementType>[] <arrayName>;


  1. Create the array


arrayname = new dataType[]


  1. Initialize the array


[]  = {};


Java Array is the most common type of data-structure which contains similar types of data value. The data items place in the array are called elements and the first element in the array starts with the index zero.

Single dimensional array declares in java:

  • int[] a=new int[5]

Multi-dimensional array declares in java:

  • int a[][] = new int[2][3];

Multi-dimensional array can be accessed by using loop.


The Highlighted Topics are Discussed Below



  • Programming and coding standards
  • Developing and implementing test plans



Java source is named as *.java and byte is code named as *.class. Java source file contains a single public class or interface. Each class is placed in a separate file. Java source files have the following orderings: package and import statements, beginning comments, class, and interface declarations (Downey, A. B. & Mayfield, C. 2019).

The header of all source files is as follows – title, version, date in mm/dd/yy, and copyright information.

Java source code guidelines are as follows:

  • Indentation.
  • Left and right braces.


  • One declaration per line.
  • Instance variables should be placed in the sequence.

Naming convention standards:

  • Naming constants.
  • Naming collections.

Software Testing is a method to check whether the actual program or application matches the expected requirements or not and to ensure that the program or application is Defect free. Testing steps are:

  • Basic functionality testing
  • Code review
  • Static code analysis


The Highlighted Topics are Discussed Below



  • Code modularization




Modularization of code is the process of dividing software into separate subcodes. A module is a separate software code. It can often be used within different of applications and functions with other components of the system.


  • Long program management is quite difficult as there might be too many syntax errors or logical errors present in the program. Modular programming helps to manage such types of program code in an easy way.
  • Each sub-module content is necessary to execute only one aspect of the desired functionality.

Benefits of modularization

  • Logical organization.
  • Code reusability.
  • Elimination of redundancy.

Abstraction is the process of paying attention to important properties while ignoring inessential details.

Java Modularization

  • Modules can be named as Java.
  • Using single method within a class.
  • In Java modularization, definition of method will be outside the main method, but in the same class.


Modifier returnValueType methodName(list of parameters) { //Method body; }


Example of using local variable

public class HelloApp


public static void main(String[] args)


String helloMessage;

helloMessage = “Hello, World!”;





The Highlighted Topics are Discussed Below



  • ArrayList.
  • Various operations on arrayList.
  • Iterators.
  • Introduction to classes and objects.



ArrayList is a part collection of frameworks and found in ‘java.util package’. Standard java arrays are of a fixed length. Array list supports dynamic arrays and can grow if needed.


ArrayList constructor


ArrayList(Collection c)

ArrayList(int capacity)



Some common operations in arrayList

  • Adding an item into an ArrayList : add()
  • Accessing an item: get()
  • Change the item: set()
  • Remove the item: remove()


An Iterator is an object that can be used to iterate through ArrayList. Method declaration is done by Iterator:


  • Boolean hasNext()
  • Object next()
  • Void remove()

Example of Iterator use:

Iterator itr = al.iterator();

Object is an instance of a class. It is real world physical entity. It can be created many times as per requirements. It allocates memory.



Object name “myObj”

public class MyClass {

int a = 50;


public static void main(String[] args) {

MyClass myObj = new MyClass();





Class is a blueprint or template of object which is created. It is a logical entity. It is declared one time. Class doesn’t allocate memory when it is created.


Class name “MyClass”


public class MyClass {

int x = 5;





Four types of access-specifiers are available in Java:

  • Private
  • Public
  • Default
  • Protected


The Highlighted Topics are Discussed Below



  • Constructors
  • Destructors
  • Setter and Getter methods



Constructoris a block of codes that is used in java as a special method. Constructor is called when an instance of the class is created. It establishes an object. There are two types of constructor is used in Java.

  • Default constructor.
  • Parameterized constructor.



Default Constructor doesn’t have any parameter. It provides the default values to the object like 0, null etc. depending on type.




Parameterized constructor has a specific number of parameters. It is used to provide different values to different objects.



The method Destructor is called when an instance of a class is destroyed. The main goal of the destructor is to free some memory space and also to clean up resources like the closing of open files, closing of database connections, closing network resources, etc, (Niemeyer, P.& Knudsen, J. 2005).


Class Object


protected void finalize()


//statements like closure of database connection



Getter and Setter are two methods that are used for retrieving and updating the value of a variable.

get – getter method to get the value.

set – setter method to set the value.





The Highlighted Topics are Discussed Below



  • Encapsulation.
  • Polymorphism.
  • Inheritance.



Encapsulation: Wrapping up of data into a single unit is called encapsulation.

  • The variables of a class are hidden from other classes and can be accessed only through the member-function of own class in which they are declared. It is known as data hiding.
  • Declaration of all the variables in the class can be featured as non-public and writing public methods in the class to set and get the values of variables

Advantages of encapsulation:

  • It improves flexibility and re-usability
  • Fields can be functioned either read-only or write-only mode


Polymorphism:Poly means ‘many’ and morphism means ‘form’. One name having many forms is called polymorphism. Polymorphism has the ability to display a message in more than one form. An example of polymorphism is – a person at the same time can have different characteristics. (Cornell, G.&Horstmann, C. S. 2008).


Polymorphism is two types:

  • Run-time polymorphism
  • Compile-time polymorphism.

Method overriding is an example of run-time polymorphism and method overloading is an example of compile-time polymorphism.

Inheritance:It is important in OOP(Object Oriented Programming). It allows one class to inherit the features of another class.

Important features of Inheritance are:

  • Super class.
  • Sub class.
  • Reusability




class derived-class extends basis class


//method and fields




The Highlighted Topics are Discussed Below



  • Array of Objects



An array is a collection of similar data types. An array of objects is created, based on the ‘Object’ class. One name is used to refer to the entire group. The array elements store the location of the reference variables of the object. Array is a dynamically created object. Once the array object is defined, it is mandatory to initialize it with values. Using the ‘sort’ method, the objects of an array can also be sorted. An array of objects is created just like an array of primitive type data items in the following way (Flanagan, D. 2002).

Class_name [] objArray;


Advantages of array:

  • It stores many elements one at a time
  • It allows random accessing of elements.
  • Predefined the size of the array is a mandatory.



Java is an object-oriented and class-based programming language. It offers a real-time possibility. It allows the definition and implementation of generic abstractions. Java is an IDE (Integrated Development Environment). It stands on class and object.



Work Cited

  1. Joyce Farrell. (2017). Programming Logic & Design Ninth Edition. Cengage Learning.
  1. Cay Horstmann. (2009).Object Oriented Design and Patterns.Wiley India Pvt. Limited
  1. Timothy Budd. (2008). An Introduction to Object-Oriented Programming Third edition. Pearson Education
  1. Danny Poo & Derek Kiong & Swarnalatha Ashok. (2008). Object Oriented Programming and Java. Springer
  1. Allen B. Downey & Chris Mayfield. (2019). Think Java second edition. O’Reilly Media
  1. Jean-Paul Tremblay & Grant A. Cheston. (2003). Data structure and software development in an object oriented domain: Java edition
  1. Patrick Niemeyer & Jonatban Knudsen. (2009). Learning Java. O’Reilly Media
  1. Cay S.Horstmann. (2008). Core Java Volume II – Fundamentals Eight edition. Pearson Education
  1. David Flanagan. (2002). Java Script: The Definitive Guide. O’Reilly

Leave A Response