Tag Archives: class

Abstract Class

In Kotlin, abstract class is declared using the abstract keyword in front of class. An abstract class can not instantiated means we can not create object for the abstract class.

Important points

      • We can’t create an object for abstract class.
      • All the variables (properties) and member functions of an abstract class are by default non-abstract. So, if we want to override these members in the child class then we need to use open keyword.
      • If we declare a member function as abstract then we does not need to annotatate with open keyword because these are open by default.
      • An abstract member function doesn’t have a body, and it must be implemented in the derived class.
      • An abstract class can contain both abstract and non-abstract members.

Continue reading Abstract Class

Follow and like us:

Class

A class is a blue print defined which groups functions and properties. Classes in Kotlin are defined using the keyword class followed by the class name. The body goes inside the curly braces.


Syntax of class in Kotlin

An instance of the class is instantiated in the following way


instance of the class

Contrary to Java, new isn’t a keyword in Kotlin.


new is not a keyword

Continue reading Class

Follow and like us: