Golang quiz or Go quiz , Solve following golang MCQs quizzes. These questions are mcq so based on their output choose any one of the correct options. You can ask your queries related to these questions in comment, we will try to answer your query.
1. How many keyword in GO?
2. Which of the following is initial value (zero value) for interfaces, slice, pointers, maps, channels and functions? ?
2. Which of the following is initial value (zero value) for interfaces, slice, pointers, maps, channels and functions?
3.What is output of the following go code ?
package main import ( "fmt" ) func main() { newPrintMethod() } func newPrintMethod(){ var i int defer fmt.Println(i) i++ defer fmt.Println(i) }
2 Comments
The solution for 3rd question is showing up incorrect. The question is below.
ReplyDeletepackage main
import (
"fmt"
)
func main() {
newPrintMethod()
}
func newPrintMethod(){
var i int
defer fmt.Println(i)
i++
defer fmt.Println(i)
}
Answer: D) 1 0 (Multiple defer calls in Golang are executed in LIFO order. So it should be 1 0 but not 0 1.
correct
ReplyDelete