AeroLab Reading room

CS / A2 level

Programming paradigms, files and practical skills

Object-oriented programming groups state and behaviour; inheritance and polymorphism express relationships but need careful interfaces. Declarative styles describe desired results rather than every execution step.

Learning objectives

The big idea

Object-oriented programming groups state and behaviour; inheritance and polymorphism express relationships but need careful interfaces. Declarative styles describe desired results rather than every execution step.

Practical programming combines data structures, file access, exception handling and systematic debugging. Use clear contracts and automated checks, protect private data and never execute untrusted input as code.

Worked example

A queue contains A then B. After removing one and adding C, what is its order?

Follow the solution

FIFO removes A, leaving B; C is appended after it.

Investigate and explain

Predict the worked result before calculating. Change one input, record the new result, and explain which assumptions still hold.

Use the prediction activity below; a local model appears only where it supports this topic.

Open the interactive investigation

Check your understanding

1. What does encapsulation support?

  1. Making every field public
  2. Controlled access to state through defined interfaces
  3. Eliminating all bugs automatically
Check the answer and reasoning

Controlled access to state through defined interfaces

Interfaces constrain how state can be manipulated and preserve invariants.

2. A queue contains A then B. After removing one and adding C, what is its order?

  1. C, B
  2. A, C
  3. B, C
Check the answer and reasoning

B, C

FIFO removes A, leaving B; C is appended after it.

3. Should a program evaluate a user-supplied string as code to parse a number?

  1. No
  2. Yes
  3. Only on a website
Check the answer and reasoning

No

Parse a bounded numeric format instead; evaluating arbitrary strings creates an unnecessary code-execution risk.