Go Data Structures and Interfaces

Assess your knowledge of slices,maps,structs,and interfaces in Go.

1. What data structure in Go is a fixed-size sequence of elements?
2. Which operations can be performed on a slice in Go?
3. Maps in Go are thread-safe for concurrent writes without synchronization.
4. What function is used to check if a key exists in a map (hint: the second return value)?
5. What is the result of len(make([]int, 5, 10))?
6. Which are valid ways to create a non-nil map in Go?
7. An empty interface (interface{}) can hold values of any type in Go.
8. What term describes converting an interface value to a concrete type using .(T)?
9. Which data structure is typically implemented using a slice with append and len for LIFO operations?
10. Which statements about structs in Go are true?
11. A nil interface (interface{}) in Go holds both a nil type and a nil value.
12. What is the capacity of a slice created with make([]int, 0, 5) after appending 3 elements?
13. What happens when you append to a slice that has reached its capacity?
14. Which are interfaces defined in the Go standard library?
15. A struct can implement multiple interfaces in Go.
16. What method must a type implement to satisfy the fmt.Stringer interface?
17. Which data structure in Go uses key-value pairs for efficient lookups?
18. Which of the following are value types in Go?
19. The zero value of a slice variable in Go is nil.
20. What is returned when accessing a key that does not exist in a non-nil map (e.g., m["key"] where m is initialized but has no 'key')?
Answered 0 of 0 — 0 correct