Imagine you are developing a student tracking system for a school in Kotlin. Each student has a name and an age. They can also introduce themselves by stating their name and age. Fill in the blanks in the given code to create a class named 'Student' with the appropriate fields and a function to introduce themselves. Test this setup by creating an instance of the 'Student' class and printing out the result of the self-introduction function.
Computer scienceProgramming languagesKotlinObject-oriented programmingObject-oriented programming basic
Declaring classes
Creating a student tracking system
Report a typo
Fill in the gaps with the relevant elements
Student( name: String, var age: Int) {
introduceSelf() = "Hello, I am $name and I am $age years old."
}
val student1 = Student("John", 20)
println(student1.introduceSelf()) ___
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.