Instructions

  • 1. Your final score will reflect your grasp of the concepts—approach each question with precision.
  • 2. Thoroughly review each solution before proceeding to ensure full understanding.
  • 3. Final results will be available after submission to provide insights into areas for further improvement.
  • 4. Maintain academic integrity—plagiarism undermines learning and professional growth.
  • 5. Once submitted, responses are final, so ensure you’re confident in your answers.
  • 6. These challenges are designed to test practical knowledge; apply your skills as you would in real-world scenarios.

All Problems

Question

Action

Which method allows operator overloading in Python?

View

What will the output be in the following code?

View

What does the term “method overriding” mean?

View

Which of the following statements about polymorphism is correct?

View

What is the role of super() in method overriding?

View

Which method allows you to implement custom behavior for string conversion?

View

What is the primary benefit of method overriding?

View

What will be printed by the following code?

View

What type of polymorphism is demonstrated when different objects are treated as instances of the same base class?

View

Which method is invoked when printing an object directly?

View

Which method allows operator overloading in Python?

__str__()
__add__()
__init__()
__subclass__()

What will the output be in the following code?

class A: def show(self): print("A's show") class B(A): def show(self): print("B's show") obj = B() obj.show()

A's show
B's show
None
Error

What does the term “method overriding” mean?

Calling a method inside another class
Redefining a method in a child class
Using private methods
Implementing abstract methods

Which of the following statements about polymorphism is correct?

Only works with private methods
Requires the use of @override decorators
Allows methods to behave differently in different contexts
Only applies to operator overloading

What is the role of super() in method overriding?

It creates a new instance of the superclass
It gives access to the parent class’s overridden method
It converts the class to an abstract class
It defines a new type of object

Which method allows you to implement custom behavior for string conversion?

__add__()
__init__()
__str__()
__call__()

What is the primary benefit of method overriding?

Reducing the code size
Avoiding the need for inheritance
Achieving runtime polymorphism
Compiling code faster

What will be printed by the following code?

class X: def display(self): print("Class X") class Y(X): def display(self): print("Class Y") obj = X() obj.display()

Class Y
Class X
None
Error

What type of polymorphism is demonstrated when different objects are treated as instances of the same base class?

Compile-time polymorphism
Method hiding
Dynamic polymorphism
Operator overloading

Which method is invoked when printing an object directly?

__print__()
__str__()
__repr__()
__name__()