1. How do you declare a constant in Go?
Answer:
Explanation:
Constants in Go are declared using the 'const' keyword followed by the constant name and its value.
2. Can a constant in Go be declared without an initial value?
Answer:
Explanation:
Constants in Go must be initialized at the time of their declaration and cannot be assigned a value later.
3. What is the type of an untyped constant in Go?
Answer:
Explanation:
Untyped constants in Go don't have a fixed type. Their type is inferred based on the context in which they are used.
4. Which of these is a valid way to declare a group of constants in Go?
Answer:
Explanation:
In Go, a group of constants can be declared inside parentheses with each constant declaration separated by a newline.
5. Which of the following is true about constant blocks in Go?
Answer:
Explanation:
In Go, constants in a block can be of different types, and it's not mandatory for each constant to be explicitly initialized if it follows an iota.
6. What does 'iota' represent in Go?
Answer:
Explanation:
'iota' is a predeclared identifier in Go representing successive untyped integer constants, used to create enumerated constants.
7. What is the zero value of an untyped boolean constant in Go?
Answer:
Explanation:
The zero value of an untyped boolean constant in Go is 'false'.
8. How does Go handle typed and untyped constants in an operation?
Answer:
Explanation:
In operations involving both typed and untyped constants, the untyped constant is converted to the type of the typed constant.
9. Are constant expressions in Go evaluated at compile-time or runtime?
Answer:
Explanation:
Constant expressions in Go are evaluated at compile time.
10. Can you use arithmetic operations on constants of different types in Go?
Answer:
Explanation:
Arithmetic operations can be performed on untyped constants of different types, as Go will infer the type based on the context. However, typed constants must be explicitly converted to a common type.