Golang Operators & Expressions Quiz
40 comprehensive questions on Go's operators and expressions, covering arithmetic, comparison, logical, and bitwise operations — with 12 code examples exploring operator precedence, short-circuit evaluation, and practical usage patterns.
Question 1
What are Go's basic arithmetic operators?
Question 2
What is the result of 7 % 3 in Go?
Question 3
What will this arithmetic expression evaluate to?
package main
import "fmt"
func main() {
result := 10 / 3
fmt.Println(result)
}Question 4
What are Go's comparison operators?
Question 5
What will this comparison return?
package main
import "fmt"
func main() {
x := 5
y := 5.0
fmt.Println(x == y)
}Question 6
What are Go's logical operators?
Question 7
What does short-circuit evaluation mean in Go?
Question 8
What will this short-circuit example print?
package main
import "fmt"
func test() bool {
fmt.Println("test called")
return true
}
func main() {
result := false && test()
fmt.Println("result:", result)
}Question 9
What are Go's bitwise operators?
Question 10
What is the result of 5 & 3 (bitwise AND)?
Question 11
What does the left shift operator << do?
Question 12
What will this bitwise operation produce?
package main
import "fmt"
func main() {
x := 12 // 1100
y := 10 // 1010
result := x ^ y
fmt.Println(result)
}Question 13
What is operator precedence in Go expressions?
Question 14
What is the result of 2 + 3 * 4 in Go?
Question 15
What will this precedence example evaluate to?
package main
import "fmt"
func main() {
result := 10 + 5 * 2 - 3
fmt.Println(result)
}Question 16
What is the associativity of most Go operators?
Question 17
What does the increment operator ++ do in Go?
Question 18
What will this increment code do?
package main
import "fmt"
func main() {
x := 5
y := x++ // This line
fmt.Println(x, y)
}Question 19
What is the result of true && false || true?
Question 20
What will this logical expression evaluate to?
package main
import "fmt"
func main() {
a := true
b := false
c := true
result := a && b || c
fmt.Println(result)
}Question 21
What does the bitwise AND NOT operator &^ do?
Question 22
What is the result of 15 &^ 10?
Question 23
What will this shift operation produce?
package main
import "fmt"
func main() {
x := 8 // 1000
result := x << 2
fmt.Println(result)
}Question 24
What happens with negative numbers in right shift?
Question 25
What will this overflow example do?
package main
import "fmt"
func main() {
var x uint8 = 255
x = x + 1
fmt.Println(x)
}Question 26
What is the result of comparing NaN values?
Question 27
What will this floating-point comparison do?
package main
import "fmt"
import "math"
func main() {
x := math.NaN()
y := math.NaN()
fmt.Println(x == y)
}Question 28
What is the result of 1 << 63 for int on a 64-bit system?
Question 29
What will this complex expression evaluate to?
package main
import "fmt"
func main() {
result := 5 > 3 && 10 < 20 || false
fmt.Println(result)
}Question 30
What does the unary ^ operator do when used alone?
Question 31
What will this bitwise NOT operation produce?
package main
import "fmt"
func main() {
x := 5 // 00000101
result := ^x
fmt.Println(result)
}Question 32
What is the difference between / and % for negative numbers?
Question 33
What will this negative modulo example produce?
package main
import "fmt"
func main() {
result := -7 % 3
fmt.Println(result)
}Question 34
What happens when you shift by more than the word size?
Question 35
What will this large shift do?
package main
import "fmt"
func main() {
x := 8
result := x << 100
fmt.Println(result)
}Question 36
What is the result of comparing interface{} values?
Question 37
What will this interface comparison do?
package main
import "fmt"
func main() {
var a interface{} = []int{1, 2}
var b interface{} = []int{1, 2}
fmt.Println(a == b)
}Question 38
What is the precedence of bitwise vs arithmetic operators?
Question 39
What will this mixed operator expression evaluate to?
package main
import "fmt"
func main() {
result := 1 + 3<<2 - 2&3
fmt.Println(result)
}Question 40
Why is understanding operator precedence important in Go?
