Quiz: Deduce the Outputs

In this lesson, your concepts will be evaluated through a quiz.

Choose one possible correct answer

1

Deduce the output of the following program:

package main
import "fmt"

type Any interface {}
type Anything struct {}

func main() {
	any := getAny()
	if any == nil {
		fmt.Println("any is nil")
	} else {
		fmt.Println("any is not nil")
	}
}

func getAny() Any {
	return getAnything()
}
func getAnything() *Anything {
	return nil
}
A)

any is nil

B)

any is not nil

C)

Compiler Error

D)

any is nil any is not nil

Question 1 of 30 attempted

Get hands-on with 1400+ tech skills courses.