How many types of constructors are there ? What are they ?
Answer / Mohit Kumar Sharma
In Kotlin, there are two types of constructors: Primary Constructors and Secondary Constructors. A Primary Constructor is a constructor that is declared in the class declaration itself and has the same name as the class. Secondary Constructors are declared inside the primary constructor with the help of init blocks or by using constructor keyword. They can have different names but must call the primary constructor.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the role of open keyword in Kotlin?
How to declare a variable in kotlin?
What is the default visibility modifier and also list the different types of modifiers?
How many constructors are available in Kotlin?
What is Data Class in Kotlin?
How to make a class data class ?
What is the difference between var and val ?
What is the difference between declaration variable using val or var in kotlin?
How to convert a String to an Integer?
What is the type of arguments inside a constructor?
Why you should switch to Kotlin from Java?
When instruction in Kotlin are executed ?