Go Quizes, Golang Quizes - 01

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)
}




 

4. Which of the language GO is?





 

5. Does GO support garbage collector?





Post a Comment

2 Comments

  1. The solution for 3rd question is showing up incorrect. The question is below.

    package 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.

    ReplyDelete