16 - Quiz¶
-
Your name:
-
Your VT email:
What happens when two strings are sent to this channel?
ch := make(chan string, 2)
- A. Both sends fail
- B. The second value overwrites the first
- C. The channel closes automatically
- D. Both values are stored in the buffer
In a buffered channel, when does a send operation block?
- A. When the buffer is empty
- B. When the buffer is full
- C. When a receiver exists
- D. When a goroutine starts
What is the purpose of the select statement in Go?
- A. To create new goroutines
- B. To wait on multiple channel operations simultaneously
- C. To select an if-condition
- D. To create buffered channels
In the bank account example, the balance variable is accessed only by the teller() goroutine.
Why is this design useful?
- A. It allows multiple goroutines to modify the balance simultaneously
- B. It ensures only one goroutine modifies the balance, avoiding race conditions
- C. It eliminates the need for channels
- D. It automatically speeds up execution