W3Tutorials.net
Toggle Menu
Home
Online Go Compiler
Tutorials
Javascript Tutorials
Python Tutorials
Go Tutorials
Blog
All Posts
Advanced Go Concepts
Dive into interfaces,embedding,and reflection in Go.
1. Which keyword is used to launch a new goroutine in Go?
go
goroutine
launch
start
2. Which of the following are synchronization primitives provided by the sync package?
sync.Mutex
sync.WaitGroup
sync.Channel
sync.Map
sync.Pool
3. An empty interface (interface{}) in Go can hold values of any type.
True
False
4. What keyword ensures a function call executes when the surrounding function exits?
5. What happens when sending to a buffered channel that is full?
The send succeeds immediately
The send blocks until a receiver reads from the channel
A panic is thrown
The channel is automatically closed
6. Which of the following are valid uses of the context package?
Propagating cancellation signals
Setting request timeouts
Managing global application state
Passing request-scoped values
Allocating memory for goroutines
7. In Go, methods can only be defined on struct types.
True
False
8. What does the sync.WaitGroup struct primarily coordinate?
Memory allocation across goroutines
The completion of a group of goroutines
Channel buffer sizes
File descriptor limits
9. Name the statement used to handle multiple channel operations simultaneously.
10. Which statements about panic and recover are correct?
Panic should replace normal error handling
Recover must be called within a deferred function
Unrecovered panic terminates the program
Recover returns nil if no panic occurred
Panic can only be triggered by runtime errors
11. Type assertions in Go can convert an interface value to a concrete type.
True
False
12. What is the purpose of the 'reflect' package?
To optimize garbage collection
To inspect and manipulate types at runtime
To handle network reflections
To synchronize goroutines
13. Which are characteristics of Go interfaces?
Explicitly implemented with 'implements' keyword
Implicitly satisfied by types with matching methods
Can contain fields
Can be embedded in structs
Support method overloading
14. A goroutine is managed by the Go runtime, not the OS kernel.
True
False
15. What does the 'go.mod' file primarily define?
Compilation flags
Module dependencies and version constraints
Goroutine pool size
Application entry point
Reset
Answered 0 of 0 — 0 correct