The work done by a conservative force field in moving a particle around a closed path is…
Blog
How many goroutines are created when the following program r…
How many goroutines are created when the following program runs? package mainimport “fmt”func doSomething(s string) { fmt.Println(s)}func main() { go doSomething(“test 1”) go doSomething(“test 2”)}
Assume that variable ch is a channel whose elements have typ…
Assume that variable ch is a channel whose elements have type int, and variable strs is a slice of string. Which of the following code fragments correctly print out all elements of strs concurrently? (assume that each of these code fragments is placed in the same main function as variable ch and variable strs)
Assume that variable ch has been declare to be a channel. Ma…
Assume that variable ch has been declare to be a channel. Match each statement on the left to the corresponding operation description.
Every running Go program has at least one goroutine, even if…
Every running Go program has at least one goroutine, even if there is no go statement in the program.
What is the output of the following program? package mainimp…
What is the output of the following program? package mainimport “fmt”import “time”func doSomething(s string) { fmt.Println(s)}func main() { go doSomething(“test 1”) go doSomething(“test 2”) fmt.Println(“main”) time.Sleep(100 * time.Millisecond)}
In the Go programming language, an interface type is defined…
In the Go programming language, an interface type is defined as a set of ____.
Match each surface to its respective equation.
Match each surface to its respective equation.
Given the following Go code fragment: type Point struct { …
Given the following Go code fragment: type Point struct { X, Y float64} Write a code fragment that makes the Point struct implement the built-in interface fmt.Stringer, assuming that the standard package fmt has been imported in the same package containing the given code fragment and your code fragment. The implementation must be done so that when calling fmt.Println to print an instance of Point, it will be printed in the following format: (X, Y)
Given the following Go program: package mainimport “fmt”type…
Given the following Go program: package mainimport “fmt”type T struct { S string }func (t *T) test(){ if t==nil { fmt.Println(“nil underlying value”) } else { fmt.Println(t.S) }}type Test interface{ test()}var myTest Testfunc main(){ var t *T myTest = t myTest.test()} Which of the following statements is true about the given program?