Creating a student tracking system

Report a typo

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.

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())
valclassfun
___

Create a free account to access the full topic