![]() In Kotlin a subclass can only be derived from a single direct parent class. For example, a subclass can also inherit from another subclass with the potential to create large and complex class hierarchies. The class from which a subclass is derived is called the parent class or superclass.Ĭlasses need not only be derived from a root class. Any number of subclasses may be derived from a class. ![]() The class at the top of the hierarchy is known as the base class or root class and the derived classes as subclasses or child classes. In fact, all classes in Kotlin are ultimately subclasses of the Any superclass which provides the basic foundation on which all classes are based.īy deriving classes we create what is often referred to as a class hierarchy. The derived class inherits all of the features of the parent class and typically then adds some features of its own. ![]() It allows a class to be defined that has a certain set of characteristics (such as methods and properties) and then other classes to be created which are derived from that class. The concept of inheritance brings something of a real-world view to programming.
0 Comments
Leave a Reply. |