📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!


    Question

    Consider the following Python code: class

    Vehicle:     def __init__(self, brand):         self.brand = brand     def display_info(self):         return f"Brand: {self.brand}" class Car(Vehicle):     def __init__(self, brand, model):         super().__init__(brand)         self.model = model     def display_info(self):         return f"{super().display_info()}, Model: {self.model}" my_car = Car("Toyota", "Camry") print(my_car.display_info()) What will be the output of this code?
    A Brand: Toyota, Model: Camry Correct Answer Incorrect Answer
    B Brand: Toyota Correct Answer Incorrect Answer
    C Model: Camry Correct Answer Incorrect Answer
    D A `TypeError` because `super().__init__(brand)` is incorrect. Correct Answer Incorrect Answer
    E An `AttributeError` because `brand` is not defined in `Car`. Correct Answer Incorrect Answer

    Solution

    The correct answer is A

    Practice Next
    ask-question