Vidyalelo
Computer Science · Q278

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 278

Q278

Both const and @JvmField create constants. What can const do that @JvmField cannot? class Detail companion object const val COLOR = "Blue" @JvmField val SIZE = "Really Big"

A.
const is compatible with Java, but @JvmField is not
B.
The compiler will inline const so it is faster and more memory efficient
Answer
C.
Virtually any type can be used with const but not @JvmField
D.
const can also be used with mutable types

Answer: Option B

Solution

Answer: Option B
No explanation is given for this question Let's Discuss on Board