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 composition in Python OOP?

View

Which of the following describes aggregation?

View

In composition, what happens when the container object is deleted?

View

Which relationship type best describes aggregation?

View

How is composition implemented in Python?

View

What happens to an aggregated object if the container object is deleted?

View

Which of these is an example of composition?

View

How do composition and inheritance differ?

View

What is the output of this code?

View

Which is a stronger relationship: composition or aggregation?

View

What is composition in Python OOP?

One class directly uses objects of another class
A class inherits multiple parent classes
A class contains another class as a part
A class with only private attributes

Which of the following describes aggregation?

Whole-part relationship
Parent-child inheritance relationship
Stronger than composition
A form of polymorphism

In composition, what happens when the container object is deleted?

All child objects are deleted
Child objects remain unaffected
Raises an exception
Deletes only class attributes

Which relationship type best describes aggregation?

"has-a" relationship
"is-a" relationship
"uses-a" relationship
"belongs-to" relationship

How is composition implemented in Python?

By creating instances of one class inside another
Using inheritance
Using the super() function
Using the abstract keyword

What happens to an aggregated object if the container object is deleted?

It is also deleted
It remains intact
It raises a warning
Python prevents its deletion

Which of these is an example of composition?

A Car class with a Wheel class inside it
A Bird class inheriting from an Animal class
Overriding a parent method
Using static methods

How do composition and inheritance differ?

Composition is stronger than inheritance
Composition allows reuse without inheritance
Inheritance restricts data access
Composition only works with abstract classes

What is the output of this code?

class Engine: def start(self): print("Engine started") class Car: def __init__(self): self.engine = Engine() c = Car() c.engine.start()

Error
Engine started
None
Engine stopped

Which is a stronger relationship: composition or aggregation?

Composition
Aggregation
Both are equal
Depends on the context