• +91 9723535972
  • info@interviewmaterial.com

Kotlin Interview Questions and Answers

Question - Where should we use var and where val in Kotlin?

Answer -

In Kotlin, var is used where value is frequently changing. For example, while getting the location of the android device:

var integerVariable : Int? = null  
In Kotlin, val is used where there is no change in value in the whole class. For example, when you want to set textview or button's text programmatically:

val stringVariables : String = "Button's Constant or final Text"  

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners