• +91 9723535972
  • info@interviewmaterial.com

Kotlin Interview Questions and Answers

Question - What do you understand by data classes in Kotlin?

Answer -

Data classes are the type of classes that are made to store some data. In Kotlin, it is marked as data. The following is an example of a data class:

data class Developer(val name: String, val age: Int)  
When we mark a class as a data class, we don't have to implement or create the following functions like we have to do in Java: hashCode(), equals(), toString(), copy(). The compiler automatically creates these internally, so it also leads to clean code. Although, there are a few other requirements that data classes need to fulfill.

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners