Go Test For Candidates
Go Test For Candidates
below.
a. To handle errors
b. To define data structures
c. To enable concurrent execution of functions
d. To declare interfaces
a. 9 bytes
b. 12 bytes
c. 6 byte
d. 8 bytes
3. What is the role of the select statement when used with channels in Go?
package main
import "fmt"
func main() {
ch := make(chan int, 1)
ch <- 1
ch <- 2
fmt.Println(<-ch)
fmt.Println(<-ch)
}
a. prints 1 and 2
b. prints 1 and 1
c. throws a runtime error
d. program gets stuck
6. What does the recover() function return when called within a deferred
function after a panic in Go?
7. In Go, what is the role of the close() function when used with a channel?