Kotlin - Data Types
Which of the following is the correct way to declare a variable of type
Any in Kotlin?Any in Kotlin?Any is non-nullable, so it cannot hold null. Assigning a string is valid.val x = null infers Any? - not type Any. B: val x: Any = null assigns null to non-nullable - invalid. C: val x: Any? = 123 declares nullable Any? - not Any. D: val x: Any = "Hello" assigns a string to Any - valid.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions