Courseiva
Object-Oriented Programming →mediumMultiple Choice

PCAP Object-Oriented Programming Practice Question

A class `Vector` defines `__add__` to return a new `Vector`. A developer writes `v1 = Vector(1,2); v2 = Vector(3,4); v3 = v1 + v2`. What is the type of `v3`?

⚠ Common exam trap

The trap here is assuming that `+` always returns a numeric type, but with operator overloading, it can return any type.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

`Vector`

Operator overloading in Python allows classes to define behavior for operators like `+`. The `__add__` method is called on the left operand, and its return value becomes the result of the expression. Since the `Vector` class implements `__add__` to return a new `Vector`, `v3` is a `Vector` instance.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    `None`

    Why it's wrong here

    If `__add__` does not explicitly return a value, it returns `None`. However, the scenario states that `__add__` is defined to return a new `Vector`. Therefore, `v3` will not be `None`. This option would be correct only if the method lacked a return statement.

  • ✓

    `Vector`

    Why this is correct

    When `v1 + v2` is evaluated, Python calls `v1.__add__(v2)`. If `__add__` is implemented to return a new `Vector` instance, then `v3` will be of type `Vector`. This is the expected behavior for operator overloading in Python, allowing custom objects to support arithmetic operations.

  • ✗

    `int`

    Why it's wrong here

    `__add__` for a custom class like `Vector` is not required to return an integer. It typically returns a new instance of the same class to support vector addition. Returning an `int` would be unusual and would break the expected behavior of vector arithmetic. The scenario specifies it returns a new `Vector`.

  • ✗

    `tuple`

    Why it's wrong here

    `__add__` can return any type, but in this scenario, the method is defined to return a new `Vector`. There is no indication that it returns a tuple. If it did, `v3` would be a tuple, but that would be a design choice, not the default. The question states the method returns a new `Vector`.

About these practice questions

One of 421 original PCAP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

This PCAP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCAP exam.