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

What is the purpose of an abstract class in Python?

View

Which module provides support for abstract classes in Python?

View

How do you define an abstract method in a class?

View

Can an abstract class contain non-abstract methods?

View

What happens if you instantiate an abstract class directly?

View

How is an interface implemented in Python?

View

Which of the following methods must be overridden in a subclass of an abstract class?

View

Which statement is true about abstract classes?

View

What is the output of the following code?

View

What will happen if Circle does not override area() in the above code?

View

What is the purpose of an abstract class in Python?

To prevent instantiation
To allow multiple inheritance
To hide private data
To override parent methods

Which module provides support for abstract classes in Python?

abstract
abc
interface
oop

How do you define an abstract method in a class?

Using @staticmethod
Using @abstractmethod decorator
Using @property decorator
By prefixing the method with __

Can an abstract class contain non-abstract methods?

Yes
No
Only in multiple inheritance
Only if all attributes are private

What happens if you instantiate an abstract class directly?

The program runs normally
An AbstractMethodError is raised
A TypeError is raised
It executes without issues but returns None

How is an interface implemented in Python?

By subclassing multiple classes
By inheriting from an abstract base class without any concrete methods
By using super()
By creating constructors

Which of the following methods must be overridden in a subclass of an abstract class?

All methods of the class
Only methods marked with @abstractmethod
Only private methods
None of the methods

Which statement is true about abstract classes?

They can only contain abstract methods
They are defined using the interface keyword
They can contain both abstract and concrete methods
Abstract classes are not allowed in Python

What is the output of the following code?

from abc import ABC, abstractmethod class Shape(ABC): @abstractmethod def area(self): pass class Circle(Shape): def area(self): return 3.14 * 5 * 5 obj = Circle() print(obj.area())

Error
78.5
None
3.14

What will happen if Circle does not override area() in the above code?

The code runs with warnings
The code raises a TypeError
The program crashes silently
It prints None