Quiz

Quiz yourself on the concepts of channels.

1

What will be the output of the program mentioned below?

package main

import "fmt"

func main() {
	var ch chan string
	var count int

	go func() {
		ch <- "Hi"
	}()

	go func() {
		count++
		close(ch)
	}()

	<-ch
	fmt.Println(count)
}
A)

The program will exit because of panic.

B)

1

C)

Can’t compile

D)

0

Question 1 of 30 attempted

Get hands-on with 1200+ tech skills courses.