Skip to main content
Northern IrelandSoftware Systems DevelopmentSyllabus dot point

What are classes, objects, attributes and methods, and how does an object oriented program model a real problem?

Classes and objects, attributes and methods, instantiation, and how the object oriented paradigm models real-world entities.

A CCEA A-Level Software Systems Development answer on the core object oriented concepts: what a class and an object are, attributes and methods, instantiation, and how the paradigm models real-world entities.

Generated by Claude Opus 4.812 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

CCEA wants you to define the building blocks of the object oriented paradigm: a class, an object, an attribute and a method. You must explain instantiation, distinguish a class (the template) from an object (the instance), and show how grouping data and behaviour together models a real-world entity. These ideas underpin every program you write in this course, so they are tested directly and assumed in later questions.

The answer

Classes and objects

A useful way to picture it: the class is the architect's plan for a house, and each object is an actual house built from that plan. Every house has the same rooms defined by the plan, but each has its own paint colour, furniture and occupants, just as each object has its own attribute values.

Attributes and methods

An attribute is a named data item that belongs to an object and stores part of its data. The collection of an object's attribute values at a given moment is called its state. A method is a named block of code, defined in the class, that performs an operation on or for the object; the methods define the object's behaviour.

Instantiation

Instantiation is the act of creating an object from a class. In most languages a constructor is called, often with the keyword new, which allocates memory for the new object and sets up its initial attribute values. Each instantiation produces a distinct object, independent of the others.

class Student
  attributes: name, yearGroup, mark
  methods: setMark(m), getGrade()

aoife = new Student("Aoife", 13)   // one object
ben   = new Student("Ben", 12)     // a separate object

Here aoife and ben are two objects of the same class. Calling aoife.setMark(78) changes only aoife's mark; ben is unaffected, because each object has its own copy of the attributes.

Worked example: modelling a real entity as a class

Examples in context

Example 1. A library system. A Book class defines attributes such as title, author and onLoan, and methods such as borrow() and returnItem(). Each physical book in the catalogue is one Book object. Borrowing one copy calls borrow() on that object and sets its onLoan attribute to true, leaving every other copy unchanged. The class is written once but models thousands of books.

Example 2. A game of characters. An Enemy class with attributes health and position and methods move() and takeDamage(amount) lets a designer create dozens of enemy objects from one definition. Each enemy tracks its own health, so damaging one does not heal another, and the shared methods give them consistent behaviour.

Try this

Q1. Define the term object and state how it relates to a class. [2 marks]

  • Cue. An object is a specific instance of a class, created at run time with its own attribute values; the class is the template from which it is built.

Q2. A Dog class has attributes name and age and a method bark(). Write a statement that instantiates a Dog object called rex, and a statement that calls its bark() method. [2 marks]

  • Cue. rex = new Dog("Rex", 3) then rex.bark().

Q3. Explain why grouping attributes and methods together in a class is described as modelling a real-world entity. [2 marks]

  • Cue. The attributes capture what the thing knows (its state) and the methods capture what it can do (its behaviour), so the class mirrors a real object's data and actions in one unit.

Exam-style practice questions

Practice questions written in the style of CCEA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

CCEA 20196 marksExplain the difference between a class and an object, using an appropriate example. In your answer refer to attributes, methods and instantiation.
Show worked answer →

A class is a blueprint or template that defines the structure and behaviour shared by a group of similar things. An object is a specific instance of a class, created at run time, with its own values stored in its attributes.

A good worked example is a Car class:

class Car
  attributes: make, model, speed
  methods: accelerate(), brake(), getSpeed()

The class names three attributes (the data each car holds) and three methods (the operations a car can perform). It does not by itself represent any particular car.

When the program runs, instantiation creates an object from the class. For example myCar = new Car("Ford", "Focus") builds one Car object whose make is "Ford" and whose model is "Focus". A second statement could create yourCar, a separate object with its own attribute values, built from the same class.

Markers reward a clear class-versus-object distinction (template versus instance), correct use of the words attribute and method, and a sensible example that shows instantiation creating a named object.

CCEA 20214 marksState what is meant by an attribute and a method, and explain how they together describe the state and behaviour of an object.
Show worked answer →

An attribute is a named data item belonging to an object that stores part of its data, for example a BankAccount object's balance. The set of an object's attribute values at any moment is its state.

A method is a named block of code, defined in the class, that performs an operation on or for the object, for example deposit(amount) or withdraw(amount). The methods define an object's behaviour, that is what it can do and how it responds to messages.

Together they model a real thing: the attributes hold what the object knows (its current state) and the methods define what it can do (its behaviour). Calling deposit(50) runs a method that changes the balance attribute, so the behaviour updates the state.

Markers reward correct definitions of attribute and method, the link of attributes to state and methods to behaviour, and a concrete example tying a method call to a change in an attribute.

Related dot points

Sources & how we know this