Recall & Review
beginner
What is an array in Go?
An array in Go is a fixed-size collection of elements of the same type stored in contiguous memory locations.
Click to reveal answer
beginner
How do you declare an array of 5 integers in Go?
You declare it like this:
var arr [5]int. This creates an array named arr that can hold 5 integers.Click to reveal answer
intermediate
What happens if you try to assign more elements than the declared size of an array in Go?
You will get a compile-time error because arrays have fixed size and cannot hold more elements than declared.
Click to reveal answer
beginner
How can you declare and initialize an array in one line in Go?
You can write:
arr := [3]int{10, 20, 30}. This creates an array of size 3 with values 10, 20, and 30.Click to reveal answer
intermediate
What is the difference between an array and a slice in Go?
An array has a fixed size known at compile time, while a slice is a flexible, dynamic view over an array that can grow or shrink.
Click to reveal answer
How do you declare an array of 4 strings in Go?
✗ Incorrect
Option B declares a fixed-size array of 4 strings. Option D and C declare slices, not arrays. Option A is invalid syntax.
What is the default value of elements in a newly declared integer array in Go?
✗ Incorrect
Integer arrays are initialized with zero values, so each element is 0 by default.
Which of these is a valid way to declare and initialize an array in Go?
✗ Incorrect
Option D correctly declares and initializes an array. Option A is a slice. Options C and D are invalid syntax.
What happens if you try to access an index outside the declared size of an array in Go?
✗ Incorrect
Accessing out-of-range index causes a runtime panic in Go.
Which statement about Go arrays is true?
✗ Incorrect
Arrays in Go have fixed size and all elements must be of the same type.
Explain how to declare and initialize an array in Go with examples.
Think about using var and shorthand := with curly braces.
You got /4 concepts.
Describe the difference between arrays and slices in Go.
Consider how flexible each type is and how they relate.
You got /4 concepts.