1. What is the default type of an integer literal in Go if it does not fit into int32?
Answer:
Explanation:
If an integer literal exceeds the size of int32, Go defaults to int64 for the literal's type.
2. Which of the following types represents a floating-point number in Go?
Answer:
Explanation:
In Go, float32 and float64 are the types used to represent floating-point numbers.
3. What is the zero value of a struct in Go?
Answer:
Explanation:
The zero value of a struct in Go is a struct with all its fields set to their respective zero values.
4. In Go, which keyword is used to define a new struct?
Answer:
Explanation:
The 'struct' keyword is used to define a new struct type in Go.
5. What is the output type of the 'make' function when used with a slice in Go?
Answer:
Explanation:
The 'make' function is used to create slices, maps, and channels in Go, and it returns a slice when used with a slice type.
6. Which data type is used to represent a sequence of characters in Go?
Answer:
Explanation:
In Go, the 'string' data type is used to represent a sequence of characters.
7. How do you declare an array of 5 integers in Go?
Answer:
Explanation:
Arrays in Go are declared by specifying the type of elements and the number of elements in square brackets before the variable name.
8. Which of the following is NOT a valid map declaration in Go?
Answer:
Explanation:
In Go, the correct syntax to declare a map either uses the 'var' keyword followed by the map type, or the ':=' syntax with the 'make' function or a map literal.
9. What is the zero value for a pointer in Go?
Answer:
Explanation:
The zero value for a pointer in Go is 'nil'.
10. Which keyword is used to define an interface in Go?
Answer:
Explanation:
Interfaces in Go are defined using the 'interface' keyword.
11. Which data type in Go is used to represent a Unicode code point?
Answer:
Explanation:
The 'rune' data type in Go represents a Unicode code point. It is an alias for int32.
12. What is the default value of a slice in Go?
Answer:
Explanation:
The zero value of a slice in Go is 'nil'.
13. How do you specify a variable-length argument list in a Go function?
Answer:
Explanation:
In Go, a variable-length argument list is specified by prefixing the type of the argument with '…'.
14. What is the key difference between a slice and an array in Go?
Answer:
Explanation:
In Go, arrays have a fixed size, while slices are a flexible view into the elements of an array and can dynamically change size.
15. What does the 'range' keyword in Go return when iterating over a map?
Answer:
Explanation:
When iterating over a map with the 'range' keyword in Go, it returns both the key and the value for each entry in the map.