Question | Click to View Answer |
What does the following code print to the console? package main
import "fmt"
func main() {
fmt.Println("hi there")
}
|
If this script is stored in a Executable commands must always use package main.
The |
What does the following code print? fmt.Println(5)
|
The |
What does the following command line command return when run in the terminal? godoc fmt Println
|
The command returns documentation on the func Println(a ...interface{}) (n int, err error) Println formats using the default formats for its operands and writes to standard output. Spaces are always added between operands and a newline is appended. It returns the number of bytes written and any write error encountered |
What does the following code print to the terminal? var x string = "hi"
fmt.Println(x)
|
The variable |
What does the following code print to the terminal? var num string = 5
fmt.Println(num)
|
This code throws the following error: The |
What does the following code print to the terminal? var coolNum int
coolNum = 8
fmt.Println(coolNum)
|
The Then Finally, the |
What does the following code print to the terminal? var goat string
goat = "mj"
goat = "lebron"
fmt.Println(goat)
|
The Variables can be reassigned in go. |
What does the following code print to the terminal? gretzkyNum := 99
fmt.Println(gretzkyNum)
|
The In Go, Go infers the |
What does the following code print to the terminal? myName := "matthew"
myName = 888
fmt.Println(myName)
|
This code throws the following error: The
|
What does the following code print to the terminal? myDinner = "hot dog"
fmt.Println(myDinner)
|
This code throws the following error: The This code works if myDinner := "hot dog"
fmt.Println(myDinner)
It also can work if the variable type is explicitly declared. var myDinner string = "hot dog"
fmt.Println(myDinner)
|
What does the following code print to the terminal? const Pi = 3.14
fmt.Println(Pi)
|
The constant |
What does the following code print to the terminal? const Greeting = "Hello!"
Greeting = "Hola!"
fmt.Println(Greeting)
|
This code throws the following error: Go constants cannot be reassigned. |