Question |
Good |
Fails |
Is Go a case sensitive language? |
7 |
1 |
Which of the following operator decreases integer value by one in Go? |
7 |
0 |
Method are special functions with a receiver in Go. |
6 |
1 |
Which of the following function returns the capacity of slice as how many elements it can be accomodate? |
4 |
3 |
Go supports method overloading. |
7 |
0 |
what does it print ?
package main
import (
"fmt"
)
func main() {
x := []int{100, 200, 300, 400, 500, 600, 700}
twohundred := &x[1]
x = append(x, 800)
for i := range x {
x[i]++
}
fmt.Println(*twohundred)
}
|
1 |
6 |
What does it print?
func main() {
m := make(map[string]int)
m["foo"]++
fmt.Println(m["foo"])
}
|
6 |
1 |
What does it print?
package main
func main() {
print(len(map[interface{}]int{
new(int): 1,
new(int): 2,
new(struct{}): 3,
new(struct{}): 4,
}))
}
|
2 |
5 |
What does it print?
package main
func main() {
type P *int
type Q *int
var p P = new(int)
*p += 8
var x *int = p
var q Q = x
*q++
println(*p)
}
|
5 |
2 |
Whats the output?
package main
import "fmt"
func foo() {
for i := 5; i > 0; i-- {
defer func() {
fmt.Print(i, " ")
}()
}
}
func main() {
foo()
}
|
4 |
3 |
What is the output of the next code?
package main
import "fmt"
func main() {
ch := make(chan int, 1)
ch <- 1
ch <- 2
fmt.Print(<-ch)
fmt.Print(" ")
fmt.Print(<-ch)
}
|
4 |
3 |
what does this program print?
package main
import "fmt"
func max(a, b int) int {
if a > b {
return a
}
panic()
}
func main() {
x := max(42, 7)
fmt.Println(x)
} |
1 |
2 |