/en-tutor-prep-s6-ict-oop-debugging-practice-3/
/en-tutor-prep-s6-ict-oop-debugging-practice-3/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

S6 ICT: object-oriented programming and debugging (challenge)

S6 ICT: object-oriented programming and debugging (challenge)

  • 2026-11-20

S6 ICT: object-oriented programming and debugging (challenge)

Going deeper: class variables, self, recursion, debuggers, unit tests and search cost.

Challenge: shared state, recursion and tooling The harder items test sharing and overhead. A class variable is shared, so creating 3 objects while adding 1 in the constructor gives 3, whereas instance variables are per object. self is the object, not the class. factorial(4) calls itself 4 times with factorial(1) as the base case. A debugger inspects every variable and steps through code without editing it. Of 20 unit tests, 3 fail and 17 pass. Searching 1000 sorted items costs 1000 comparisons for linear search in the worst case and about 10 for binary search.

01 Paper details (check answers afterwards)

Item Detail
Questions 10
Suggested time 25
Difficulty mix Foundation 3 · Intermediate 3 · Challenge 3 · Error redo 1
Chapter Chapter: S6 ICT: Object-Oriented Programming and Debugging
Level Challenge (10 items)

02 Questions (10 items)

  1. FoundationHow do a class variable and an instance variable differ?
  2. FoundationWhat does self represent inside a method definition?
  3. FoundationWho receives the parameters passed when an object is created?
  4. IntermediateA class variable count starts at 0 and the constructor adds 1 each time an object is created. What is count after 3 objects?
  5. IntermediateHow many times does the recursive function factorial(4) call factorial, counting the outermost call?
  6. IntermediateHow does a static method differ from an instance method?
  7. ChallengeWhat are the advantages of a debugger breakpoint over many print statements?
  8. ChallengeOf 20 unit tests, 3 fail. How many pass?
  9. ChallengeSearching 1000 sorted items, how many comparisons does linear search need in the worst case, and about how many for binary search?
  10. Error redoCorrect three confusions: self is the class name; every object has its own class variable; recursion is always faster than a loop.

03 Answers and one-line notes

# Answer One-line note
1 A class variable is shared by all objects and exists once; an instance variable exists separately in every object. Ask whether the value should be shared between objects; if so, use a class variable.
2 The object on which the method is called, used to reach that object attributes and other methods. self is the object, not the class, so it points to a different instance for each object.
3 The constructor __init__ receives them and assigns them to instance variables through self. Parameters exist only at creation time; they become lasting attributes once assigned to self.
4 3, because the class variable is shared and every increment lands on the same copy. With an instance variable each object would count from 0 and the value would be 1 instead.
5 4 times: factorial(4), factorial(3), factorial(2) and factorial(1). factorial(1) is the base case and returns 1 without recursing further.
6 A static method takes no self and cannot touch object state; an instance method takes self and can read or write attributes. Helper computations that need no object data suit a static method.
7 It shows every variable at once, steps line by line and allows editing a value before continuing, all without changing the source or leaving output noise. A debugger shows the real state; print shows only what you thought to print.
8 17 pass. Remove the failures first and the rest pass; a test report normally lists both counts.
9 Linear search needs up to 1000 comparisons; binary search needs about 10, since 2 to the power 10 is 1024, which covers 1000 items. Binary search halves the range on each comparison, so the count grows with the base-2 logarithm.
10 self is the object itself; a class variable is shared by all objects; recursion speed depends on call overhead and is never guaranteed faster. Recursion buys clarity and pays with call overhead and a stack depth limit.

04 What to do after marking

  • After marking, redo only the wrong items and write down which step went wrong (formula, unit, or misread number).
  • Repeat the same item two days later; move to the next paper only when both attempts are correct.
  • Parents only need the answer and note columns; there is no need to explain every item.

Want to separate class from object and inheritance from polymorphism, then debug with a real debugger instead of scattered print calls? Book a TutorZone tutor and link the concepts to practice in twenty-five minutes.Tutor Registration →

Questions and answers are written originally by the TutorZone team and are not taken from any school, publisher or examination authority paper. Every value is checked by computer.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →