Learn in your language
Skip to content
A Level · Cambridge (CIE) · 9618

20 Further programming

Compare programming paradigms, trace low-level addressing and build robust file-processing programs with exception handling.

Cambridge International AS & A Level Computer Science 9618 · 2027–2029 · Version 2 · 20

Mapped to Cambridge International AS & A Level Computer Science 9618, 2027–2029 Version 2. These original lessons and self-checks are independent study support; they are not Cambridge papers, official marks or grades. The course does not yet provide a timed four-paper simulation or a locked-down Paper 4 programming environment.

Before you begin

  • Use the 2027–2029 syllabus for your exam year. AS candidates study Sections 1–12; A Level candidates study Sections 1–20. Paper 4 uses a programming language chosen from Python, Java or Visual Basic in console mode.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

Which paradigm commonly groups state and behaviour into objects?

What you will learn

  • Explain the key representations, structures or processes in this syllabus section
  • Apply the method to a new computer-science example
  • Justify a design choice and check its limits

Paradigms are different ways to structure solutions

Low-level code works close to the processor and may use immediate, direct, indirect, indexed or relative addressing. Imperative procedural code uses variables, sequence, selection, iteration, procedures and functions.

Object-oriented programming organises state and behaviour in objects and can support encapsulation, inheritance and polymorphism. Functional programming emphasises expressions and function application; declarative programming states relationships or desired results. Choose a paradigm for the problem rather than treating one as universally best.

Reverse Polish notation (RPN) places operators after operands and can be evaluated with a stack. For 3 4 + 2 ×, push 3 and 4, add them, push 2, then multiply.

Robust file processing handles data and failure

A program should open a file using the intended mode, check whether records remain, process each record and close the file even after an error. Exception handling catches defined failures such as a missing file or invalid conversion and provides a safe response.

File processing may require validation, buffering and explicit output handling. Exception handling should not silently hide a data error; record or report what failed and preserve a recoverable state.

Pause and explain

Why should an exception handler identify the expected failure?

Put the idea to work

Worked example

Evaluate the RPN expression 5 2 − 3 × using a stack.

Show the worked solution
  1. Push 5, then push 2.
  2. The operator − pops 2 then 5 and computes 5−2=3.
  3. Push 3; × combines 3 and 3 to produce 9.

Answer 9.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

Trace the RPN expression 8 3 − 2 ÷. Show the stack result after each operator.

Give me a hint

For subtraction and division, the second popped value is the left operand.

Compare my reasoning
  1. Push 8 and 3; subtract as 8−3=5.
  2. Push 2; divide as 5÷2.
  3. The expression's result is 2.5 when real division is used.

2.5 (with real division; integer division rules would need to be stated separately).

Look for these in your work

  • Operand order correct
  • Second operation correct
  • Division assumption stated
2 · Independent

A program reads a file of numeric scores, but the file may be missing or contain a non-numeric line. Describe a safe handling plan.

Give me a hint

Treat file access and data conversion as separate failure points.

Compare my reasoning
  1. Attempt to open the file and handle a missing-file error with a clear message or recovery path.
  2. For each line, validate or convert the value inside a narrow error handler.
  3. Report the invalid line and continue only if the program's data policy allows; always close the file.

Handle file-open and conversion failures separately, report the problem, and close the file safely.

Look for these in your work

  • Missing file addressed
  • Bad data addressed
  • Cleanup and reporting included
3 · Transfer

A team is building an interactive simulation with many entities whose state changes independently. Compare an object-oriented and a functional design and recommend what to prototype.

Give me a hint

Compare state organisation with transformations over data; justify based on expected change.

Compare my reasoning
  1. Objects can encapsulate each entity's state and behaviour.
  2. A functional design can express state updates as transformations and make pure calculations easier to test.
  3. Prototype the entity interactions and update flow, then compare clarity, testability and performance for the workload.

Prototype both representations around a representative interaction and choose based on clarity, testability and measured performance.

Look for these in your work

  • Both paradigms represented
  • A meaningful comparison
  • Recommendation evidence-based

Common mistakes

  • Reversing operand order for a subtraction in RPN.
  • Using exception handling to ignore every error without reporting it.
  • Confusing a class definition with a particular object instance.
Recall without your notes

What can you explain now?

In RPN, what does the operator do with the top two stack values?

Compare with the explanation

It pops operands in order, applies the operator and pushes the result.

For subtraction and division, operand order matters: the second popped value is the left operand.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

How do procedural, object-oriented, functional and declarative approaches differ, and what does a robust file-processing routine protect against?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science

Course scope and assessment

This pathway maps the 2026 Version 2 and 2027–2029 Version 2 syllabuses, which Cambridge says have no significant changes affecting teaching. It has original teaching and guided, independent and transfer practice for all 20 syllabus sections, with topic links to the official section headings. It is mapped teaching, not proof of exam readiness or an official Cambridge grade. Paper 4 requires complete programs and testing evidence in a programming environment; the current course offers explained code and algorithm practice but does not yet provide a locked-down timed programming-paper environment, full four-paper mocks or human subject-teacher review.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.