What are the different types of constructors in Kotlin?

devquora
devquora

Posted On: Jun 24, 2024

 

There are two types of constructors in Kotlin:

  • Primary constructor: It is a section of the Class header and is declared after the class name.
  • Secondary constructor: This constructor is declared inside the body.

Note: There can be more secondary constructors for a class.

    Related Questions

    Please Login or Register to leave a response.

    Related Questions

    Kotlin Interview Questions

    What is Kotlin?

    Kotlin is an open-source language combining object-oriented programming features. Notable features include range expressions, extension functions, companion objects, smart casts, and data classes, off..

    Kotlin Interview Questions

    Which type of Programming does Kotlin support?

    Kotlin supports OOP with classes and objects, FP with higher-order functions and immutability, and procedural programming for sequential execution, catering to diverse software development approaches...