Golang Data Types & Zero Values Quiz
40 comprehensive questions on Go's built-in types, zero values, type inference, conversions vs casting, and aliased types — with 20 code examples to master type safety and initialization.
Question 1
What are Go's basic built-in types?
Question 2
What is the zero value of an int variable?
Question 3
What is the zero value of a bool variable?
Question 4
What is the zero value of a string variable?
Question 5
What is the zero value of a pointer variable?
Question 6
What will this code print?
package main
import "fmt"
func main() {
var x int
var y bool
var z string
fmt.Println(x, y, z)
}Question 7
What is type inference in Go?
Question 8
What will this code output?
package main
import "fmt"
func main() {
x := 42
y := 3.14
z := "hello"
fmt.Printf("%T %T %T\n", x, y, z)
}Question 9
What is the difference between conversion and casting?
Question 10
What will this conversion do?
package main
import "fmt"
func main() {
var x int32 = 1000
var y int16 = int16(x)
fmt.Println(y)
}Question 11
What is an aliased type in Go?
Question 12
What will this code print?
package main
import "fmt"
func main() {
type Celsius float64
var temp Celsius = 20.5
fmt.Printf("%T %v\n", temp, temp)
}Question 13
What is the zero value of a slice?
Question 14
What is the zero value of a map?
Question 15
What will this code output?
package main
import "fmt"
func main() {
var s []int
var m map[string]int
fmt.Println(s == nil, m == nil)
}Question 16
What happens when you convert a float to int?
package main
import "fmt"
func main() {
var f float64 = 3.9
var i int = int(f)
fmt.Println(i)
}Question 17
What is the output of this type inference example?
package main
import "fmt"
func main() {
a := 1
b := 2.0
c := a + int(b)
fmt.Println(c)
}Question 18
What is the zero value of a channel?
Question 19
What will this aliased type code do?
package main
import "fmt"
type Kilograms float64
type Pounds float64
func main() {
var kg Kilograms = 10
var lbs Pounds = Pounds(kg)
fmt.Println(lbs)
}Question 20
What is the output of this zero value demonstration?
package main
import "fmt"
func main() {
var (
i int
f float64
b bool
s string
p *int
)
fmt.Printf("%v %v %v %q %v\n", i, f, b, s, p)
}Question 21
What is the range of int in Go?
Question 22
What will this conversion output?
package main
import "fmt"
func main() {
var x int = 257
var y byte = byte(x)
fmt.Println(y)
}Question 23
What is the zero value of a function variable?
Question 24
What will this type inference do?
package main
import "fmt"
func main() {
x := []int{1, 2, 3}
fmt.Printf("%T\n", x)
}Question 25
What is the output of this string conversion?
package main
import "fmt"
func main() {
var i int = 65
var s string = string(i)
fmt.Println(s)
}Question 26
What is the zero value of a rune?
Question 27
What will this aliased type code do?
package main
import "fmt"
type MyInt int
func main() {
var x MyInt = 42
var y int = int(x)
fmt.Println(y)
}Question 28
What is the output of this float conversion?
package main
import "fmt"
func main() {
var f float32 = 1.5
var i int = int(f)
fmt.Println(i)
}Question 29
What is the zero value of an array?
Question 30
What will this type assertion do?
package main
import "fmt"
func main() {
var i interface{} = 42
s := i.(string)
fmt.Println(s)
}Question 31
What is the output of this complex type inference?
package main
import "fmt"
func main() {
x := 1 + 2.0
fmt.Printf("%T %v\n", x, x)
}Question 32
What is the zero value of a struct?
Question 33
What will this conversion do?
package main
import "fmt"
func main() {
var b []byte = []byte("hello")
s := string(b)
fmt.Println(s)
}Question 34
What is the output of this aliased type example?
package main
import "fmt"
type Celsius float64
type Fahrenheit float64
func main() {
var c Celsius = 20
var f Fahrenheit = Fahrenheit(c + 32)
fmt.Printf("%T %v\n", f, f)
}Question 35
What is the zero value of a complex number?
Question 36
What will this code print?
package main
import "fmt"
func main() {
var x uint8 = 255
x++
fmt.Println(x)
}Question 37
What is the output of this type inference with constants?
package main
import "fmt"
func main() {
const x = 42
y := x
fmt.Printf("%T %v\n", y, y)
}Question 38
What is the zero value of a rune?
Question 39
What will this conversion do?
package main
import "fmt"
func main() {
var s string = "hello"
b := []byte(s)
fmt.Println(b)
}Question 40
Why does Go require explicit conversions?
