IB COMPUTER SCIENCE | B3 ASSESSMENT

OBJECT-ORIENTED PROGRAMMING: END OF TOPIC REVIEW

Assess class design, object state, access rules and HL relationships and patterns through scored retrieval, applied traces and developed written responses.

BEFORE YOU BEGIN

This review covers all ten B3 objectives. Use several sessions if needed: quick checks, applied traces, then written construction and explanations. B3.1 is common SL/HL; B3.2 is HL-only. The basic OOP ideas named in B3.1.1 remain common content.

Sections A and B award one point for each fully correct automatic item, with no partial credit within an item. Section C has separately suggested content marks. These are original practice questions, not an official IB paper, grade boundary or prediction.

Choose your level below. Write calculations, diagrams and Section C answers in your exercise book before revealing guidance. Answers and selections last while the page remains open.

Automatic total: 48 points. Suggested written total: 84 marks, assessed separately.

A | QUICK CHECKS

Answer without notes. A1–A22 and B1–B32 are common SL/HL; A23–A24 and B33–B34 are HL-only. Section C has 16 common tasks and two HL tasks. Select every correct answer in checkbox items.

A1 | Which correctly distinguish classes and objects?

Select all correct answers. One point requires the complete correct set.

A2 | Which are balanced reasons for choosing OOP?

Select all correct answers. One point requires the complete correct set.

A3 | Which features belong in a useful method contract?

Select all correct answers. One point requires the complete correct set.

A4 | Which UML statements are correct?

Select all correct answers. One point requires the complete correct set.

A5 | Which should normally be instance state in this school model?

Select all correct answers. One point requires the complete correct set.

A6 | Which static-method statements are correct?

Select all correct answers. One point requires the complete correct set.

A7 | Which statements about initialization are correct?

Select all correct answers. One point requires the complete correct set.

A8 | Which statements about references are correct?

Select all correct answers. One point requires the complete correct set.

A9 | Which support information hiding?

Select all correct answers. One point requires the complete correct set.

A10 | Which Python access statements are correct?

Select all correct answers. One point requires the complete correct set.

A11 | Which are appropriate for a current-only BookCopy model?

Select all correct answers. One point requires the complete correct set.

A12 | Which tests would help detect class-design defects?

Select all correct answers. One point requires the complete correct set.

A13 | Which fit inheritance?

Select all correct answers. One point requires the complete correct set.

A14 | Which base-initialization statements are correct?

Select all correct answers. One point requires the complete correct set.

A15 | Which describe dynamic overriding?

Select all correct answers. One point requires the complete correct set.

A16 | Which describe Java overloading?

Select all correct answers. One point requires the complete correct set.

A17 | Which apply to abstract classes?

Select all correct answers. One point requires the complete correct set.

A18 | Which statements about abstract requirements are correct?

Select all correct answers. One point requires the complete correct set.

A19 | Which fit composition in the report model?

Select all correct answers. One point requires the complete correct set.

A20 | Which fit aggregation in the club model?

Select all correct answers. One point requires the complete correct set.

A21 | Which singleton statements are reasonable?

Select all correct answers. One point requires the complete correct set.

A22 | Which factory statements are correct?

Select all correct answers. One point requires the complete correct set.

A23 | Which observer statements are correct?

Select all correct answers. One point requires the complete correct set.

A24 | Which access-rule statements are correct in Java?

Select all correct answers. One point requires the complete correct set.

B | APPLY YOUR KNOWLEDGE

Run each question from its stated fresh program state. Do not carry additional changes from one answer to another. Programs P1–P2 are common SL/HL. Programs P3–P6 and the Java dispatch scenario are HL-only. Trace on paper before entering answers.

The compact examples isolate the stated concept. P2 assumes a valid initial charge. P5 assumes valid non-negative integer updates and synchronous callbacks; it intentionally does not include a full validation or callback-error policy.

PROGRAM P1
class Counter:
    created = 0
    def __init__(self, value=0):
        Counter.created += 1
        self.value = value
    def add(self, amount):
        self.value += amount

a = Counter(2)
b = Counter(7)
alias = a
alias.add(3)
a = b
alias.add(1)
a.add(2)
PROGRAM P2
class Battery:
    def __init__(self, level):
        self._level = level
    @property
    def level(self):
        return self._level
    def use_power(self, amount):
        if type(amount) is not int or amount < 0 or amount > self._level:
            return False
        self._level -= amount
        return True

battery = Battery(15)
first = battery.use_power(10)
second = battery.use_power(8)
PROGRAM P3 | HL ONLY
class Device:
    def report(self):
        return "Device"
class Robot(Device):
    def report(self):
        return "Robot"
class Sensor(Device):
    pass
outputs = [item.report() for item in [Robot(), Sensor()]]
PROGRAM P4 | HL ONLY
from abc import ABC, abstractmethod
class Resource(ABC):
    @abstractmethod
    def summary(self):
        pass
    def preview(self):
        return "Preview: " + self.summary()
class Article(Resource):
    def summary(self):
        return "Read"
class Unfinished(Resource):
    pass
article = Article()
result = article.preview()
PROGRAM P5 | HL ONLY
class Board:
    def __init__(self):
        self.score = 0
        self.listeners = []
    def subscribe(self, observer):
        if observer not in self.listeners:
            self.listeners.append(observer)
    def unsubscribe(self, observer):
        if observer in self.listeners:
            self.listeners.remove(observer)
    def set_score(self, score):
        if score == self.score:
            return False
        self.score = score
        for observer in tuple(self.listeners):
            observer.update(score)
        return True
class Log:
    def __init__(self):
        self.entries = []
    def update(self, score):
        self.entries.append(score)
board = Board()
display = Log()
history = Log()
board.subscribe(display)
board.subscribe(history)
board.set_score(3)
board.unsubscribe(history)
board.set_score(5)
last_result = board.set_score(5)
PROGRAM P6 | HL ONLY
class Student:
    def __init__(self, name):
        self.name = name
        self.points = 0
class Club:
    def __init__(self, members):
        self.members = list(members)
    def disband(self):
        self.members.clear()
sam = Student("Sam")
source = [sam]
robotics = Club(source)
coding = Club(source)
source.clear()
sam.points += 1
robotics.disband()
JAVA DISPATCH SCENARIO | HL ONLY

Device declares public String report(), and Robot overrides it to return "Robot". Reporter overloads show(Device) and show(Robot). The first returns "Device overload: " + device.report(); the second returns "Robot overload: " + robot.report(). In main, Device item = new Robot(); then reporter.show(item) is called. Assume all required classes and the reporter instance are defined correctly.

B1 | P1: how many Counter objects were created?
B2 | P1: what is alias.value at the end?
B3 | P1: what is b.value at the end?
B4 | P1: is a the same object as b at the end?
B5 | P1: what is Counter.created at the end?
B6 | Fresh P1 plus alias.created = 99: what is Counter.created?
B7 | P2: what is first?
B8 | P2: what is second?
B9 | P2: what is battery.level after both calls?
B10 | P2: which proposed changes would undermine the intended invariant?

Select all correct answers. One point requires the complete correct set.

B11 | Which UML operation best represents P2 use_power?
B12 | A copy can be available or borrowed. Which design choices fit?

Select all correct answers. One point requires the complete correct set.

B13 | P3: what is outputs[0]?
B14 | P3: what is outputs[1]?
B15 | For the Java dispatch scenario, what is returned?
B16 | P4: what is result?
B17 | Fresh P4: what happens if Resource() is attempted?
B18 | Fresh P4: can Unfinished() ordinarily be instantiated?
B19 | P5: how many entries are in display.entries?
B20 | P5: how many entries are in history.entries?
B21 | P5: what is last_result?
B22 | P6: how many students remain in coding.members?
B23 | P6: what is coding.members[0].points?
B24 | A caller requests create_notice("email") and receives a suitable Notice. Which creation approach is shown?

CHECK SECTIONS A AND B

Unanswered items receive zero. Each checkbox item requires all correct choices and no incorrect extras. Written marks are separate. Changing an answer or level requires resubmission.

C | WRITTEN COMMUNICATION AND SUBJECT KNOWLEDGE

Write in your exercise book before revealing the guidance. The table gives practical guidance based on the IB command terms supplied in the guide; it is not the Cambridge command-word table.

In particular, IB compare focuses on similarities, while distinguish asks for differences. If you need to address both, the question can request each separately. All main commands below are highlighted.

IB command term What to provide here Practical approach
Compare Similarities, referring to both throughout Use both to identify a shared property.
Suggest A possible answer or solution Apply relevant knowledge to propose a suitable test or approach.
Construct Information in diagrammatic or logical form Supply complete code/algorithm, including initialization, stopping and failure paths.
Trace Follow and record actions of an algorithm Separate arguments, variables, decisions, outputs and returned results.
Calculate A numerical result with relevant working Show counts or formula stages before the answer.
Describe A detailed account Give relevant features and an ordered process where useful.
Explain A detailed account including reasons or causes Link correct ideas using because, therefore, resulting in or leading to.
Compare and contrast Similarities and differences, referring to both throughout Use both for shared properties and whereas for differences.
Distinguish Clear differences State how roles or behaviours differ.
Evaluate An appraisal weighing strengths and limitations Connect trade-offs to the scenario and support the conclusion.

A connective earns no automatic mark by itself: it must express an accurate relationship. For example, “a rejected battery request leaves state unchanged, therefore an excessive request cannot make the stored charge negative through that operation” explains a mechanism and consequence. Suggested marks reward subject content, not extra unofficial grammar marks.

C1 | EVALUATING OOP FOR A LIBRARY

6 suggested marks | COMMON SL/HL

Evaluate using OOP for a school library with many book copies and borrowing rules. Include two strengths, a relevant limitation and a justified judgement.

C2 | DESIGN A BOOK COPY

6 suggested marks | COMMON SL/HL

Construct a UML class diagram for a current-only BookCopy with a unique copy ID and optional current borrower ID. Include borrow(member_id), return_book() and is_available(). Describe the result of borrowing an already borrowed copy.

C3 | CLASS STATE VERSUS OBJECT STATE

6 suggested marks | COMMON SL/HL

Distinguish between instance and class/static attributes using student scores and a shared school label. Include how static and instance methods differ in their receiving context. Explain the effect of assigning a.school in Python when school originally exists only on Student.

C4 | CONSTRUCTION AND REFERENCE TRACING

6 suggested marks | COMMON SL/HL

Trace P1 in your book, recording a, b and alias as references to object X or Y. Explain why the final values differ and state the number of constructed objects.

C5 | CONTROLLED BATTERY UPDATES

6 suggested marks | COMMON SL/HL

Explain how P2 protects battery state. Suggest tests for a valid request, an excessive request and a negative request. Discuss why an underscore alone is insufficient.

C6 | CONSTRUCT A CONTROLLED COUNTER

6 suggested marks | COMMON SL/HL

Construct a Python class or Java class for a StepCounter starting at zero. Provide read access to the count and add_steps(amount), which accepts positive whole-number amounts, returns a Boolean and leaves state unchanged on rejection. Explain one useful test.

C7 | CHOOSE AND TEST AN OBJECT MODEL

6 suggested marks | COMMON SL/HL

Describe how to test two BookCopy objects and an alias to one of them. Explain why these tests reveal more than a single successful borrowing test.

C8 | REUSE THROUGH INHERITANCE

6 suggested marks | HL ONLY

Explain how Robot can reuse Device initialization and extend its behaviour with a scan counter. Address super and one access restriction in Java.

C9 | OVERLOADING AND OVERRIDING

6 suggested marks | HL ONLY

Distinguish between Java overloading and overriding. Explain the returned string in the Java dispatch scenario using both declared and actual types.

C10 | ABSTRACTION AND MODULAR CODE

6 suggested marks | HL ONLY

Explain how P4 uses an abstract class to establish a common interface and share working code. Include what happens for Resource() and why implementation still needs testing.

C11 | COMPOSITION AND AGGREGATION

6 suggested marks | HL ONLY

Compare composition and aggregation in terms of their shared whole–part role. Then distinguish their ownership and lifetime rules using a report and a club. Include UML notation.

C12 | CHOOSE SUITABLE DESIGN PATTERNS

6 suggested marks | HL ONLY

Explain a suitable pattern for each requirement: shared settings in one controlled runtime, selecting a notice product, and refreshing several score listeners. Include a limitation of each.

C13 | TRACE REFERENCES AND LIFETIME

6 suggested marks | HL ONLY

Trace P6, recording the three membership-list sizes and the identity of their student references. Explain why disbanding Robotics does not remove Sam from Coding.

C14 | EXTEND AND TEST A RESOURCE PORTAL

6 suggested marks | HL ONLY

Construct a design plan for a resource portal with Article and Video products, a common preview operation and two listeners for publication changes. Evaluate whether a singleton is needed.

CHECK THE QUALITY OF YOUR WRITING

Did you answer the command? For explain, check the reason or cause; for compare, address both items through similarities; for compare and contrast, include differences too; for discuss, balance relevant factors in context; for distinguish, make the differences explicit; for evaluate, weigh strengths and limitations and support your conclusion.

For construct, check labels, connections and completeness. For calculate, show enough working to follow your method and label units. Select two weak responses and rewrite them after revising. Keep the written total separate from your automatic result.

YOUR NEXT REVISION STEP

Submit the automatic sections for targeted revision links.

Record your own written marks using the suggested points. Choose two weaknesses and attempt new examples after revising. Use the B3 revision page for worked content and a personal flashcard list, or return to the IB course index.