Exercise: Deduce the Outputs

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

Choose one possible correct answer.

1

If the following program is written in file main.go, and is executed via the command line as go run main.go Evan Michael Laura what will the output be?

package main
import (
	"fmt"
	"os"
	"strings"
)

func main() {
	who := "World"
	
	if len(os.Args) > 1 { // os.Args[0] == hello_who
		who = strings.Join(os.Args[1:], " ")
	}
	fmt.Println("Hello", who, "!")
}
A)

Hello Evan Michael Laura !

B)

Hello World !

C)

Hello Evan Michael Laura World !

Question 1 of 20 attempted

Get hands-on with 1200+ tech skills courses.