/en-tutor-prep-s6-ict-oop-debugging-practice-2/
/en-tutor-prep-s6-ict-oop-debugging-practice-2/
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 (intermediate)

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

  • 2026-11-20

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

Moving on: encapsulation, inheritance and polymorphism, plus exception handling and dry running.

Intermediate: encapsulation, inheritance and tracing The three pillars must stay distinct. Encapsulation hides data behind methods; inheritance lets a subclass reuse the parent definition, and a grandchild object in a three-level chain can call methods from 3 levels; polymorphism gives one method name several implementations. Overriding happens between parent and child, overloading inside one class. Of 3 calls to one function, 1 raises and 2 finish normally. Dry running x from 0 over range(1, 5) gives x = 10 after 4 iterations, and reading index 4 of a 4-element list raises IndexError.

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 Intermediate (10 items)

02 Questions (10 items)

  1. FoundationWhat is encapsulation for, and how is it achieved?
  2. FoundationWhat does inheritance give a subclass?
  3. FoundationWhat does polymorphism mean?
  4. IntermediateWith parent, child and grandchild forming three levels of inheritance, one grandchild object is created. How many levels of methods can it call?
  5. IntermediateHow does overriding differ from overloading?
  6. IntermediateOne function is called 3 times and 1 call raises an exception that try/except catches. How many calls complete normally?
  7. ChallengeDry run: x = 0; for k in range(1, 5): x = x + k. What is x at the end and how many iterations run?
  8. ChallengeA list holds 4 elements and the program reads index 4. What happens?
  9. ChallengeWhat is the most effective order for locating a bug?
  10. Error redoCorrect three confusions: encapsulation means hiding methods; inheritance copies the parent code; polymorphism means one method has only one behaviour.

03 Answers and one-line notes

# Answer One-line note
1 It hides data inside the class and allows reading or writing only through methods, so outside code cannot corrupt it; private attributes and accessor methods achieve this. Encapsulation protects data integrity; it is not about hiding methods.
2 The subclass automatically receives the attributes and methods of the parent class and may add its own parts, so shared code is written once. Write only the differences in the subclass and keep shared logic in the parent, so one edit covers all.
3 Different classes may share a method name with different implementations, and a call runs the version belonging to the object class. Polymorphism relies on overriding, so the caller needs only the method name, not the object class.
4 3 levels: methods defined in the parent, the child and the grandchild are all callable. Inheritance accumulates, so the bottom object carries the whole chain.
5 Overriding redefines a parent method in a subclass with the same name and parameters; overloading keeps one name with different parameter counts or types to form several versions. Overriding happens between parent and child; overloading happens inside one class.
6 2 calls; the except block takes over the failing call and the program continues. try/except does not erase the error; it replaces the default handling so the program can go on.
7 x = 10 and the loop runs 4 times, with k taking 1, 2, 3 and 4. range(1, 5) excludes 5, so the count is 4 and the running total adds 1, 2, 3 and 4.
8 An IndexError is raised, because the valid indexes are only 0 to 3. Indexes start at 0, so the largest index is one less than the element count.
9 Reproduce it reliably first, then narrow the range by commenting out sections or bisecting, and finally change one thing and rerun. Reproduce, narrow, then fix; change one place at a time so the effect of each change is clear.
10 Encapsulation protects data behind an interface; inheritance reuses the parent definition rather than copying it; polymorphism gives one method name several behaviours. The three target different things: data, code reuse and call behaviour.

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 →