Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
How would you complete the code to demonstrate the hierarchy of exceptions in Kotlin? Fill in the blanks to create a function that catches different types of exceptions in order.Hierarchy of exceptions
Catch me if you can, Exception edition
Report a typo
Fill in the gaps with the relevant elements
fun demonstrateExceptionHierarchy() {
{
ArithmeticException("Division by zero")
} (e: RuntimeException) {
println("Caught RuntimeException: ${e.message}")
} catch (e: ) {
println("Caught Exception: ${e.message}")
} catch (e: ) {
println("Caught Throwable: ${e.message}")
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.