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

PHP Basics: An Introduction to PHP

PHP Basics: An Introduction to PHP

Why Learn PHP? PHP is a widely-used, open-source scripting language that has been designed specifically for web development. It offers a range of benefits over its competitors, such as Microsoft's ASP, including: Easy integration with popular databases like MySQL and...

Boost Your WordPress Website with these WordPress plugins

Boost Your WordPress Website with these WordPress plugins

As a WordPress user, I know how important it is to have a website that performs well. A slow website can drive visitors away and hurt your search engine ranking. Fortunately, there are many WordPress plugins available that can help you improve your website's...

A Database: What is it?

A Database: What is it?

Introduction to Databases In today's digital age, data is the new oil. The amount of data generated every day is enormous, and businesses are finding it challenging to manage and process this data efficiently. This is where a database comes into play. Databases are a...

Call Now Button