Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 4 subjective questions More on OOP concepts

ECAP776 20 questions with model answers. Write yours first, then compare.

Read the notes Practice MCQs
  1. Question 1 of 20

    Define function overloading. Does Python support traditional function overloading based on parameter types or parameter count?

  2. Question 2 of 20

    Explain how default arguments can be used to simulate function overloading in Python, with an example.

  3. Question 3 of 20

    Describe how *args and **kwargs help implement flexible or overloaded-like functions in Python.

  4. Question 4 of 20

    Compare the use of default arguments, *args, and explicit type checking as alternatives to function overloading in Python.

  5. Question 5 of 20

    What is functools.singledispatch? Explain how it provides type-based function dispatch in Python.

  6. Question 6 of 20

    Explain operator overloading in Python. Why is it useful in user-defined classes?

  7. Question 7 of 20

    Design a Vector2D class that overloads the + operator. Explain what happens when two vector objects are added.

  8. Question 8 of 20

    Distinguish among __add__(), __radd__(), and __iadd__() in Python operator overloading.

  9. Question 9 of 20

    Explain the purpose of returning NotImplemented from an overloaded operator method. How does it differ from raising NotImplementedError?

  10. Question 10 of 20

    Describe how comparison operators can be overloaded in Python. Include the roles of __eq__() and __lt__().

  11. Question 11 of 20

    What is the relationship between __eq__() and __hash__() when operator overloading is used for value equality?

  12. Question 12 of 20

    Explain how the @functools.total_ordering decorator reduces the work needed to overload ordering operators.

  13. Question 13 of 20

    Differentiate between operator overloading and method overriding in Python.

  14. Question 14 of 20

    Define method overriding and illustrate it using a base class and a derived class.

  15. Question 15 of 20

    Explain the role of super() in an overridden method. Why is it preferable to directly naming the parent class in many situations?

  16. Question 16 of 20

    Explain how Python's method resolution order (MRO) affects method overriding in multiple inheritance.

  17. Question 17 of 20

    Describe cooperative method overriding in multiple inheritance and state the conditions required for it to work correctly.

  18. Question 18 of 20

    How do abstract methods relate to method overriding? Explain using the abc module.

  19. Question 19 of 20

    Compare method overriding with simply adding a new method to a subclass. Discuss interface compatibility.

  20. Question 20 of 20

    Develop a Python example that combines method overriding and operator overloading, and explain how both forms of polymorphism operate.

That's unit 4

Long answers stick best when they're tested again soon. Run the MCQs on this unit, then come back to the questions you found hardest.