Loading

Quipoin Menu

Learn • Practice • Grow

Direction: Choose the correct option

Q1.

What is polymorphism in OOP?
A. Encapsulation
B. Ability to present the same interface for different data types
C. Multiple inheritance
D. Method overriding
Direction: Choose the correct option

Q2.

What is method overloading in Python?
B. Python does not support traditional overloading; you can use default arguments or variable-length arguments
C. Having multiple parameters
D. Defining multiple methods with same name
Direction: Choose the correct option

Q3.

What does duck typing mean?
A. Objects must inherit from a base class
B. If it looks like a duck and quacks like a duck, it's a duck
C. Types must be explicit
D. Only ducks can swim
Direction: Choose the correct option

Q4.

What is the result of `len('hello')` and `len([1,2])`?
A. 5 and 2
B. Error
C. 5 and 2
D. 5 and 2
Direction: Choose the correct option

Q5.

How can you enforce that a subclass implements a particular method?
A. Use `@override`
B. Raise NotImplementedError in the base class
C. Use `@abstractmethod` from `abc` module
D. Both A and B
Direction: Choose the correct option

Q6.

What is the purpose of `isinstance(obj, cls)`?
A. Check if object equals class
C. Return the class
D. Check if object is an instance of a class (polymorphism aid)
Direction: Choose the correct option

Q7.

What does the `+` operator demonstrate?
A. Concatenation only
B. Operator overloading (polymorphism)
C. Addition only
Direction: Choose the correct option

Q8.

What is the output of `class A: def f(self): return 'A'; class B: def f(self): return 'B'; objects = [A(), B()]; [o.f() for o in objects]`?
A. ['A','B']
B. ['A','B']
C. ['A','B']
D. ['A','B']
Direction: Choose the correct option

Q9.

What is operator overloading?
A. Using operators with built-in types
B. Defining custom behavior for operators like `+`, `-` for user-defined classes
D. Overloading function operators
Direction: Choose the correct option

Q10.

How do you define `+` for a custom class?
A. Define `__sum__` method
B. Define `__add__` method
C. Define `__plus__` method
D. Define `__concat__` method