Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is a const? How does it differ from a val?



What is a const? How does it differ from a val?..

Answer / Mamta Sonkar

A 'const' in Kotlin is a constant value that must be initialized at compile-time. It cannot be reassigned even if the variable is not an object or a function reference.nnOn the other hand, a 'val' is a constant variable that can be reassigned within its declaration if it is an object or a function reference.nnFor example:nnconst val PI: Double = 3.14nval MY_OBJECT: SomeClass? = nullnMY_OBJECT = AnotherClass() // Valid for val, but not for const

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Kotlin Interview Questions

Who created Kotlin programming language and when?

1 Answers  


What is the equivalent of switch expression in Kotlin? How does it differ from switch?

1 Answers  


How is kotlin integrated with Gradle?

1 Answers  


What is Kotlin?

1 Answers  


What is the extension of Kotlin file?

1 Answers  


How are Primary Constructors different from Secondary Constructors ?

1 Answers  


How to convert a String to an Integer?

1 Answers  


How do you migrate the code from Java to Kotlin ?

1 Answers  


Can you tell me what kinds of programming types does Kotlin support?

1 Answers  


What are the major features of Kotlin?

1 Answers  


How does interoperable feature work in Kotlin for java ?

1 Answers  


Is there any disadvantage of Kotlin ?

1 Answers  


Categories