Consider the code given below and choose the correct option.
package main
import (
"fmt"
)
func recovery() {
recoverPanic := recover()
fmt.Println("From Recovery: ", recoverPanic)
}
func getValue(array []int, index int) int {
defer recovery()
if len(array) > index {
return array[index]
} else {
panic("Array Index out of bound")
}
}
func main() {
intArray := []int{10, 5, 15, 20, 25}
fmt.Println(getValue(intArray, 0))
getValue(intArray, 5)
fmt.Println("end of main")
}

From Recovery:  <nil>
10
From Recovery:  Array Index out of bound
end of main

10
From Recovery:  Array Index out of bound
end of main

From Recovery:  <nil>
From Recovery:  Array Index out of bound
end of main

From Recovery:  <nil>
From Recovery:  Array Index out of bound
10
end of main

Verified Answer
Correct Option - a

To get all Infosys Certified Go Developer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in