Photo AI

Last Updated Sep 27, 2025

Objects (OOP) Simplified Revision Notes

Revision notes with simplified explanations to understand Objects (OOP) quickly and effectively.

user avatar
user avatar
user avatar
user avatar
user avatar

231+ students studying

Objects (OOP)

Overview

In Object-Oriented Programming (OOP), a class is a blueprint that defines the structure and behaviour of objects. An object is an instance of a class, representing a specific entity with attributes (data) and methods (functions) that define its state and behaviour. Understanding how to create and use objects is fundamental to OOP and is essential for writing organised, reusable, and modular code.

Objects in OOP

Defining and Creating Objects

  • An object is a specific instance of a class, with its own values for the attributes defined in the class.
  • To create an object, you call the class as though it were a function, passing in any necessary data for initialisation.
  • This creates a unique instance with its own data, distinct from other instances of the same class.
lightbulbExample

Example:

class Car:
    def __init__(self, make, model):
        self.make = make
        self.model = model

# Creating objects of the Car class
car1 = Car("Toyota", "Corolla")
car2 = Car("Honda", "Civic")

Here, car1 and car2 are objects (or instances) of the Car class. Each object has its own unique values for make and model.

Object Attributes

  • Attributes represent the state of an object and are defined within the class.
  • Each object has its own set of attribute values, which can vary from one instance to another.
lightbulbExample

Example:

print(car1.make)  # Output: Toyota
print(car2.make)  # Output: Honda

Even though car1 and car2 are instances of the same class (Car), they have different values for the make attribute.

Object Methods

Methods are functions defined within a class that describe the behaviours of objects. They can use and modify the object's attributes.

lightbulbExample

Example:

class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def introduce(self):
        print(f"Hi, I'm {self.name} and I'm {self.age} years old.")

# Creating a Person object and calling its method
person1 = Person("Alice", 30)
person1.introduce()  # Output: Hi, I'm Alice and I'm 30 years old.

Modifying Object Attributes

You can change the values of an object's attributes directly or by using methods, allowing objects to update their state during the program's execution.

lightbulbExample

Example:

person1.age = 31  # Directly modifying an attribute
print(person1.age)  # Output: 31

Interacting with Multiple Objects

Each object operates independently, so you can create multiple instances of a class, each with its own attribute values and behaviours.

lightbulbExample

Example:

person2 = Person("Bob", 25)
person1.introduce()  # Output: Hi, I'm Alice and I'm 31 years old.
person2.introduce()  # Output: Hi, I'm Bob and I'm 25 years old.

Example Program: Objects in Action

infoNote

Below is an example program that defines a Book class and creates multiple Book objects.

class Book:
    def __init__(self, title, author, year):
        self.title = title
        self.author = author
        self.year = year

    def get_description(self):
        return f"{self.title} by {self.author}, published in {self.year}"

# Creating Book objects
book1 = Book("1984", "George Orwell", 1949)
book2 = Book("To Kill a Mockingbird", "Harper Lee", 1960)

# Accessing attributes and calling methods on objects
print(book1.get_description())  # Output: 1984 by George Orwell, published in 1949
print(book2.get_description())  # Output: To Kill a Mockingbird by Harper Lee, published in 1960

In this example:

  • book1 and book2 are objects of the Book class, each with its values for title, author, and year.
  • The get_description method displays the details of each book, showing how each object retains its unique data.

Tracing and Modifying Objects

Tracing Object Attributes:

To trace an object, you can inspect its attribute values at any point in the program.

lightbulbExample

Example:

print(book1.title)  # Outputs: 1984

Modifying an Object's State:

You can update an object's state by changing its attributes directly or through methods.

lightbulbExample

Example:

book1.year = 1950  # Updates the publication year
print(book1.get_description())  # Output: 1984 by George Orwell, published in 1950

Note Summary

infoNote

Key Takeaways

  • Object Creation: Objects are created from classes and hold their state through attributes.
  • Independent Instances: Each object operates independently, with its data and methods.
  • Encapsulation of Data and Behaviour: Objects bundle both data (attributes) and actions (methods), keeping them together and providing modular functionality.
Books

Only available for registered users.

Sign up now to view the full note, or log in if you already have an account!

500K+ Students Use These Powerful Tools to Master Objects (OOP)

Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!

70 flashcards

Flashcards on Objects (OOP)

Revise key concepts with interactive flashcards.

Try Computer Science Flashcards

7 quizzes

Quizzes on Objects (OOP)

Test your knowledge with fun and engaging quizzes.

Try Computer Science Quizzes

29 questions

Exam questions on Objects (OOP)

Boost your confidence with real exam questions.

Try Computer Science Questions

27 exams created

Exam Builder on Objects (OOP)

Create custom exams across topics for better practice!

Try Computer Science exam builder

12 papers

Past Papers on Objects (OOP)

Practice past papers to reinforce exam experience.

Try Computer Science Past Papers

Other Revision Notes related to Objects (OOP) you should explore

Discover More Revision Notes Related to Objects (OOP) to Deepen Your Understanding and Improve Your Mastery

96%

114 rated

Object Oriented Languages

Classes (OOP)

user avatar
user avatar
user avatar
user avatar
user avatar

326+ studying

191KViews

96%

114 rated

Object Oriented Languages

Attributes (OOP)

user avatar
user avatar
user avatar
user avatar
user avatar

246+ studying

200KViews

96%

114 rated

Object Oriented Languages

Methods (OOP)

user avatar
user avatar
user avatar
user avatar
user avatar

448+ studying

182KViews

96%

114 rated

Object Oriented Languages

Inheritance (OOP)

user avatar
user avatar
user avatar
user avatar
user avatar

265+ studying

183KViews
Load more notes

Join 500,000+ A-Level students using SimpleStudy...

Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!

97% of Students

Report Improved Results

98% of Students

Recommend to friends

500,000+

Students Supported

50 Million+

Questions answered