Vidyalelo
Computer Science · Q246

Kotlin Programming MCQ for Competitive Exams, Interviews, and Certifications

Engineering and GATE · Computer Science · question 246

Q246

What is the correct syntax to convert the String "42" to a Long in Kotlin?

A.
val l: Long = (Long)"42"
B.
val l: Long = Long.parselong("42")
C.
val l: Long = <Long>"42"
D.
val L: Long = "42".toLong()
Answer

Answer: Option D

Solution

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