What is the difference between the declarations of COLOR and SIZE?
class Record{
companion object {
const val COLOR = "Red"
val SIZE = "Large"
}
}
class Record{
companion object {
const val COLOR = "Red"
val SIZE = "Large"
}
}A. Since COLOR and SIZE are both immutable, they are identical internally
B. Both are immutable, but the use of the keyword const makes COLOR slower and less space efficient than SIZE
C. const makes COLOR faster, but not compatible with Java. Without const, SIZE is still compatible with Java
D. Both are immutable, but the use of the keyword const makes COLOR faster and more space efficient than SIZE
Answer: Option D

Join The Discussion