You need to create an object of a 'Person' class in Kotlin. The 'Person' class should have two properties: 'name' of type String and 'age' of type Int. When an instance of the 'Person' class is created, it should automatically print a statement displaying the 'name' and the 'age'. Fill the blanks in the given code to implement the required functionality.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming basic
Constructors
Creating a 'Person' class with name and age properties
Report a typo
Fill in the gaps with the relevant elements
class ( name: String, val age: Int) {
{
println("Person instance is created with name = $name and age = $age")
}
}
fun main() {
val person = Person(name = "John", age = 25)
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.