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 abstraction in OOP?

View

Which module in Python provides support for abstract classes?

View

What is the purpose of an abstract class?

View

What will happen if you try to instantiate an abstract class?

View

How do you mark a method as abstract in Python?

View

What will this code output?

View

Can an abstract class contain concrete (fully defined) methods?

View

What is the purpose of the ABC class?

View

What must a subclass do if it inherits from an abstract class?

View

What is the output of this code?

View

What is abstraction in OOP?

Hiding implementation details from the user
Creating multiple constructors for a class
Binding data and functions together
Changing object state

Which module in Python provides support for abstract classes?

abc
abstract
meta
abstract_class

What is the purpose of an abstract class?

To create objects with partial implementations
To enforce method implementation in subclasses
To initialize instance variables
To hide the parent class methods

What will happen if you try to instantiate an abstract class?

It raises an error.
It returns a default instance.
It creates a dummy object.
It initializes with None.

How do you mark a method as abstract in Python?

Using @abstractmethod decorator
Using the abstract keyword
Using @classmethod decorator
With a double underscore prefix

What will this code output?

from abc import ABC, abstractmethod class A(ABC): @abstractmethod def display(self): pass

No output; it only defines the class.
Error
Prints "Abstract class"
Initializes an object

Can an abstract class contain concrete (fully defined) methods?

Yes
No
Only if they are private
Only if the class has no abstract methods

What is the purpose of the ABC class?

To create regular classes
To mark a class as abstract
To restrict inheritance
To overload operators

What must a subclass do if it inherits from an abstract class?

Implement all abstract methods
Provide at least one abstract method
Call super() in every method
Define a constructor

What is the output of this code?

from abc import ABC, abstractmethod class A(ABC): @abstractmethod def show(self): pass class B(A): def show(self): print("Class B") obj = B() obj.show()

Class B
Error
None
Class A