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 companion object?
Can you migrate the code from java to kotlin?
In kotlin, can we create an empty array?
What are the major features of Kotlin?
What is the extension of Kotlin file?
How can you handle null exceptions in Kotlin?
What are the modifier available in Kotlin ?
Give example to declare variable using both val and var in Kotlin?
Explain the Main features of kotlin which are not available in java?
What is the default visibility modifier and also list the different types of modifiers?
How are Primary Constructors different from Secondary Constructors ?
Give me name of the extension methods Kotlin provides to java.io.File