Abstraction in Python MCQs Exercise I
Ques 1
Abstraction
What is abstraction in Python?
A Hiding implementation details
B Exposing implementation details
C Creating complex data structures
D Ignoring error handling
Ques 2
Abstraction
What is the purpose of an abstract method in Python?
A It's used for private functionality.
B It's automatically inherited from the base class.
C It's optional to implement in the derived class.
D It must be implemented in the derived class.
Ques 3
Abstraction
In Python, what is the purpose of providing default implementations in an abstract class?
A To prevent derived classes from overriding methods.
B To make the class non-abstract.
C To provide a starting point for derived classes.
D To increase the speed of method execution.
Ques 4
Abstraction
What is the output of the following python Code?
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
pass
class Circle(Shape):
def __init__(self, radius):
self.radius = radius
def area(self):
return 3.14 * self.radius * self.radius
circle = Circle(5)
print(circle.area())
A 31.4
B 78.5
C 15.7
D Error: Cannot instantiate abstract class