Vidyalelo
Computer Science · Q277

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 277

Q277

In this code snippet, why does the compiler not allow the value of y to change? for(y in 1..100) y+=2

A.
y must be declared with var to be mutable
B.
y is an implicitly immutable value
Answer
C.
y can change only in a while loop
D.
In order to change y, it must be declared outside of the loop

Answer: Option B

Solution

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