In the below program, we are creating a student class to input and print the student data like name, age. It is a simple example of creating class in Kotlin.
Note:
- The compiler creates a default constructor if we do not declare a constructor.
- Class properties must be initialized.
Program for student class in Kotlin
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer