Kotlin - Null Safety
Which of the following Kotlin expressions correctly uses the Elvis operator to assign a default value of 10 when
num is null?num is null??: and is used as variable ?: defaultValue.?: correctly with a numeric default. val result = num ? 10 uses a single question mark which is invalid. val result = num ?: "10" uses a string default which is a type mismatch if num is numeric. val result = num ??: 10 uses ??: which is invalid syntax.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions