Object-Oriented Programming

March 24, 2023

Objected-oriented programming is a complicated topic that whole textbooks can be written about. Object-oriented programming has simplified coding to a significant degree and is now essentially a staple of modern computer programming. In short, object-oriented programming allows objects, which in Java are represented using classes, to be easily used by other classes and other packages. Packages are generally collections of classes, interfaces, enums, and records that perform particular functions using code. A package can be used by other programs and extended to meet the design needs of the application. Usually, this is done by importing the package as a module to be used by the application.

For example, say we have a class

public class Person {

private int age;

private String name;

private String description;

// The constructor

public Person(int age, String name, String description) {

this.age = age;

this.name = name;

this.description = description;


// The getter functions

public int getAge() {

return age;


public String getName() {

return name;


public String description() {

return description;



Notice in the above class there are private class variables but public getters. This is generally the convention in creating classes to be used by other applications.

Another Java application can then import this class for its own use generally by typing something like using packageName.className at the top of the application.

Another application might extend this class to improve the functionality of the class or to meet the design needs of their application.

An  example might be:

public class policeOfficer extends packageName.Person {

int age;

String name;

String description;

public policeOfficer(int age, String name, String description) {

super(age, name, description); // Super here calls the superclass that is being extended. In this case the Person class above.


public void eatDonuts() {

// Of course there would be a function like this.

System.out.println(“Officer ” + name + ” is currently eating donuts.”);


public void arrestPerson() {

// Of course there would be a function like this.

System.out.println(“Officer ” + name + ” is arresting someone.”);


// The above function didn’t exist in the original Person class above.


Object-oriented programming is a very complex area of computer science. For more information about Object-oriented programming or other computer science or computer programming topics, I recommend this website page here. I also recommend the book Head First Design Patterns: Building Extensible & Maintainable Object-Oriented Software by Eric Freeman and Elisabeth Robson with Kathy Sierra and Bert Bates.

To view more blog posts from our company visit our blog section here.

Related Posts

A Comprehensive Guide to Flexbox

A Comprehensive Guide to Flexbox

Background Before diving into the details of Flexbox, let's understand its background and purpose. The Flexbox Layout module, also known as Flexible Box, is a W3C Candidate Recommendation. It aims to provide a flexible way to lay out, align, and distribute space among...

The evolution of the web: A Journey from Web 1.0 to Web 3.0

The evolution of the web: A Journey from Web 1.0 to Web 3.0

In the ever-changing landscape of the internet, the terms “Web 1.0,” “Web 2.0,” and “Web 3.0” are frequently used to describe different eras of online development. However, these terms are often misunderstood and used interchangeably. In this article, we will delve...

What is a Website?

What is a Website?

In today's digital age, a website plays a crucial role in establishing an online presence for individuals, businesses, and organizations. It serves as a platform to share information, promote products or services, connect with an audience, and facilitate various...

Call Now Button