Conclusion

You’re approaching the end of this module and getting closer to becoming proficient in Kotlin Classes. This lesson gives you another aspect of this topic - the power of overriding.

In this lesson, you learned:

  • Overriding methods is a powerful tool that promotes code reusability, flexibility and polymorphism.
  • The open modifier on the method of a base class allows you to override it in a subclass.
  • Properties in constructors can also be overridden.
  • equals() and hashCode() are two methods responsible for class instance identity.
  • You can control how instances of a class are recognized as being the same or different by implementing the equals() and hashCode().
  • You can use super to access the implementation of the base class.
See forum comments
Download course materials from Github
Previous: Demo Next: Quiz: Override Methods