Java programming course: 1.3 What is object oriented programming?

This is Lesson 1.3 of the Java programming course.


What is object-oriented programming?

Object-oriented programming is an attempt to model the real world more closely when developing software, compared to procedural languages. The two key terms you need to understand at this stage are class and object:

  • class: this is a like a template or blueprint that models something from the real-world (such as a person, product, event, role, etc.).
  • object: this is a specific instance of a class (such as a particular person, a particular product, a particular event, a particular role, etc.) and that can store its own data and responding to messages sent to it.

Simple object-oriented example

To give an example, suppose you want to model an animal. When naming a class, it is conventional to use a singular noun with its initial letter capitalised, so you might call the class Animal.

Now you have decided to create an Animal class, you need to think about two types of things that are common to all animals; its attributes (i.e., what it is composed of) and its behaviours (i.e., what it can do in response to a request):

  1. What attributes will it need? You might consider the following:
    > Each animal will have a name (e.g.,, Fido, Cuddles, etc.) 
    > Each animal will have a gender (male or female) 
    > Each animal will be a certain number of years old  

  2. What behaviours will it need? You might consider the following:
    > Another object might want to know a particular animal's name
    > Another object might want to know a particular animal's gender
    > Another object might want to know a particular animal's age
      

Java variables and methods

In Java, each attribute value is stored in an area of memory known as a variable and each aspect of its behaviour is defined in a method. Variables and methods are given unique names so that they can be identified.


The next lesson will discuss how Java programs are developed.

Lesson 1.4 How Java programs are developed


Print
×
Stay Informed

When you subscribe, we will send you an e-mail whenever there are new updates on the site.

Related Posts

 

Comments

No comments made yet. Be the first to submit a comment
Monday, 27 October 2025

Captcha Image