ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
What is throw in Kotlin?
Correct Answer: C — Used to explicitly throw an exception
In Kotlin, throw is a keyword used to explicitly throw an exception. This helps in signaling errors that must be handled.
fun checkAge(age: Int)
{
if (age < 18)
{
throw IllegalArgumentException("Age must be 18 or older.")
}
}