Vidyalelo
Computer Science · Q147

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 147

Q147

Which line of code shows how to display a nullable string's length and shows 0 instead of null?

A.
println(b!!.length ?: 0)
B.
println(b?.length ?: 0)
Answer
C.
println(b?.length ?? 0)
D.
println(b == null? 0: b.length)

Answer: Option B

Solution

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