aımnova
DashboardMy LearningCrash CoursesStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Crash Courses
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Teachers
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aımnova

IB study, practice and feedback built around the real exam.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.c1e448f

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 7.2Abstraction
Back to Computer Science HL Topics
7.2.34 min read

Abstraction (Computer Science HL)

IB Computer Science · Unit 7

Smart study tools

Turn reading into results

Move beyond passive notes. Answer exam-style questions, get AI feedback, and build the skills that earn top marks.

Get Started Free

Contents

  1. 1Expose what is needed, hide the rest
  2. 2Abstract classes and interfaces
  3. 3Designing the right interface
  4. 4Exam-style question
The big idea: Abstraction means showing only the operations a user needs, and hiding how they are done.

A driver turns a key. Combustion, timing and fuel injection all happen — none of them are on the dashboard.
AbstractionEncapsulation
Question answeredWhat should be visible?How is it protected?
Concerned withDesign — the interfaceImplementation — access control
Achieved byAbstract classes, interfaces, method designprivate, protected, getters and setters
PurposeReduce what a caller must understandStop invalid state being created
Not the same thing, and routinely swapped: They work together, so answers blur them. Abstraction decides what the outside world should see. Encapsulation enforces it.

If a question asks for both, give the distinction above in one sentence each.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
from abc import ABC, abstractmethod

class PaymentMethod(ABC):
    @abstractmethod
    def pay(self, amount):        # no body — a requirement, not a behaviour
        pass

    def receipt(self, amount):    # shared behaviour all children get
        return f"Paid {amount:.2f}"

class Card(PaymentMethod):
    def pay(self, amount):
        return "charged to card"

# PaymentMethod()  -> error: it is abstract, so it cannot be instantiated
abstract class PaymentMethod {
    abstract String pay(double amount);    // no body — a requirement, not a behaviour

    String receipt(double amount) {        // shared behaviour all children get
        return String.format("Paid %.2f", amount);
    }
}

class Card extends PaymentMethod {
    @Override String pay(double amount) {
        return "charged to card";
    }
}

// new PaymentMethod()  -> error: it is abstract, so it cannot be instantiated

Abstract class

  • Cannot be instantiated — it describes a kind, not a thing
  • May hold some implemented methods and shared attributes
  • A child must implement every abstract method
  • Use when children share real behaviour

Interface

  • Only the signatures — a pure contract
  • A class can implement many interfaces
  • Use when unrelated classes must offer the same operations
  • "Can-do" rather than "is-a"

What both give

  • A guarantee that the method exists on every implementer
  • Which is exactly what polymorphic code depends on
  • Callers depend on the promise, never on any one class
Why abstract classes cannot be instantiated: An abstract method has no body. An object of that class could be asked to run a method that does not exist — so the language refuses to create one.

It is a promise about children, not a thing in its own right.

Know your predicted grade

Take timed mock exams and get detailed feedback on every answer. See exactly where you're losing marks.

Try Mock Exams FreeYour first topic is free to keep • No credit card required

What a good abstraction does

  • Names operations in the caller's language — deposit(), not updateBalanceField()
  • Leaves no way to reach a partially-updated state from outside
  • Can be re-implemented completely with no caller changing
  • Is small: every extra public method is a promise that must be kept forever
Abstraction makes code modular: Behind a fixed interface each class becomes a module: one programmer can write PaymentMethod's children while another writes the checkout that calls pay(), and either can be tested or replaced on its own.
The leak test: If a caller must know how something works to use it correctly, the abstraction has leaked.

A method called saveToMySQL() forces every caller to know the database. save() does not — and can be changed later without anyone noticing.

How this is tested — you must distinguish abstraction from encapsulation, and justify hiding something specific. It comes up two ways:

Paper 2 — working with code

  • Explain abstraction, 3-4 marks
  • Distinguish it from encapsulation
  • State why an abstract class cannot be instantiated

Paper 2 — the algorithmic-thinking question

  • Design an abstract class or interface for a scenario
  • Explain what a change of implementation would cost
The classic trap: Answering "abstraction means hiding data". That is encapsulation. Abstraction is about what is exposed — the interface — not about access modifiers.
IB-style questionExplain[5 marks]

A weather app fetches data from an online service. Explain how an abstract WeatherSource class with a getForecast() method helps when the provider is changed.

Model answer plan

See the answer broken into clear points, with guidance on how each point earns marks.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Abstraction. Write your answer and get instant AI feedback — just like a real IB examiner.

how abstraction helps a team of programmers develop modular code. [2 marks]

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

7.1.1Fundamentals of OOP7.1.2Designing classes7.1.3Static vs non-static7.1.4Classes and objects
View all Computer Science HL topics
Improve your exam techniqueCommand terms, paper structure, and mark-scheme tips for Computer Science HL
Previous7.2.2PolymorphismNextComposition and aggregation7.2.4

4 questions to test your understanding

Reading is just the start. Students who tested themselves scored 82% on average — try IB-style questions with AI feedback.

Start FreeView All Computer Science HL Topics