Groovy Quiz 11 | Exception Handling


Reference video | Groovy Playground


1 Point for every correct answer | Let’s Get Started

1.

Guess the output

try{
    int num = 1/0
}catch(Exception exp){
    println "I am inside exception block"
    println "Exception is "+exp
}
 
 
 

2.

Guess the output

try{
    int num = 1/0
}catch(Exception exp){
    println "I am inside exception block"
    println "Exception is "+exp.getMessage()
}
 
 

3.

Guess the output

try{
    int num = 1/0
}catch(Exception exp){
    println "I am inside exception block"
}
println "I am outside exception"
 
 
 

4.

Guess the output

try{
    int num = 1/0
}catch(ArithmeticException exp1){
    println "I am inside block to catch arithmetic exception"
}catch(Exception exp){
    println "I am inside exception block"
}
println "I am outside exception"
 
 
 

5.

Guess the output

try{
    int num = 1/0
}catch(Exception exp){
    println "I am inside exception block"
}catch(ArithmeticException exp1){
    println "I am inside block to catch arithmetic exception"
}
finally{
    println "I am inside finally block"
}
println "I am outside exception"
 
 
 

6.

Guess the output

try{
    int num = 1/1
}catch(Exception exp){
    println "I am inside exception block"
}catch(ArithmeticException exp1){
    println "I am inside block to catch arithmetic exception"
}
finally{
    println "I am inside finally block"
}
println "I am outside exception"
 
 

7.

Guess the output

try{
    int num = 1/1
}
finally{
    println "I am inside finally block"
}
println "I am outside exception"
 
 
 

9