ITPEC FE Subject B October 2025 Question 6

Source exam: ITPEC FE Subject B October 2025Topic: OOP & Inheritance

ITPEC FE Subject B October 2025 — Question 6 of 20

f1 is a Rectangle(5, 2), f2 is a Cuboid(9, 4, 7) (subclass of Rectangle).

  • f1.enlarge(f2) calls Rectangle.enlarge, which adds f2.length (9) to f1.length (5) and f2.width (4) to f1.width (2)
  • Result: f1.length = 14, f1.width = 6
  • f1.output() prints (14, 6)

Why not others:
- (5, 2): ignores the enlarge call entirely

- (5, 2, 7): f1 is a Rectangle, has no height field — cannot output three values

- (9, 4): confuses f2's original dimensions with f1's result

- (9, 4, 7): outputs f2's values instead of f1's

- (14, 6, 7): incorrectly assumes f1 has a height field

Key rule: When a superclass method receives a subclass object as an argument, it only accesses fields defined in the parameter's declared type (Rectangle), not the subclass-specific fields (height).

AI-generated — may contain errors

The original exam layout is preserved in the image so diagrams, formulas, tables, and code remain accurate.

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official FE past-paper collection or Report an issue.