Go Programming Mcqs
Q.1: What is an idiomatic way to customize the representation of a custom struct in a formatted string?b
A. There is no customizing the string representation of a type.<
B. Build it in pieces each time by calling individual fields.:
C. Implement a method String() string"
D. Create a wrapper function that accepts your type and outputs a string.F
Q.2: If you iterate over a map in a for range loop, in which order will the key:value pairs be accessed?c
A. In pseudo-random order that cannot be predicted/
B. In reverse order of how they were added, last in first out:
C. Sorted by key in ascending order
D. In the order they were added, first in first out0
Q.3: What is the correct syntax ta start a goroutine that will print Hello Gopher!?N
A. go(fmt.Println("Hello Gopher!"))!
B. go func() { fmt.Println("Hello Gopher!") }+
C. go fmt.Println("Hello Gopher!")
D. Go fmt.Println("Hello Gopher!")
Q.4: How can you compile main.go to an executable that will run on OSX arm64 ?I
A. Set GOOS to arm64 and GOARCH to darwin.'
B. Set GOOS to osx and GOARCH to arm64.$
C. Set GOOS to arm64 and GOARCH to osx.$
D. Set GOOS to darwin and GOARCH to arm64.'
Q.5: What is the common way to have several executables in your project?C
A. Have a cmd directory and a directory per executable inside it.>
B. Comment out main.
C. Use build tags.
D. Have a pkg directory and a directory per executable inside it.>
Q.6: Which file names will the go test command recognize as test files?B
A. Any that starts with test
B. Any files that include the word test$
C. Only files in the root directory that end in _test.go5
D. Any that ends in _test.go
Q.7: How should you log an error (err)!
A. Log.Error(err)
B. log.Printf("error: %v", err)
C. log.Printf(log.ERROR, err)
D. log.Print("error: %v", err)
Q.8: Which is a valid Go time format literal?(
A. "2006-01-02"
B. "YYYY-mm-dd"
C. "y-mo-d"
D. "year-month-day"
Q.9: What does log.Fatal do?
A. It raises a panic.
B. It prints the log and then raises a panic.*
C. It prints the log and then safely exits the program.4
D. It exits the program.
Q.10: How is the behavior of t.Fatal different inside a t.Run?8
A. There is no difference.
B. T.Fatal does not crash the test harness, preserving output messages.D
C. T.Fatal stops execution of the subtest and continues with other test cases.K
D. T.Fatal stops all tests and contains extra information about the failed subtest.P

Related Mcqs

All Subject Mcqs