You are asked to ensure that certain attributes in a Car class should never be overridden by any child class. Which mechanism would you use to ensure this?

  • @final decorator (custom)
  • @property decorator
  • method overriding
  • private attributes
To ensure that certain attributes in a Car class should never be overridden by any child class, you can use private attributes. By convention, prefix attribute names with an underscore (e.g., _attribute) to indicate that they should not be accessed or overridden externally.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *