Vidyalelo
Computer Science · Q202

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 202

Q202

Which snippet correctly shows setting the variable max to whichever variable holds the greatest value, a or b, using idiomatic Kotlin?

A.
val max3 = a.max(b)
B.
val max = a > b ? a : b
C.
val max = if (a > b) a else b
Answer
D.
if (a > b) max = a else max = b

Answer: Option C

Solution

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