গো (Go) — MCQ প্রশ্ন
আইটি ও প্রোগ্রামিং MCQ (ওপেন) · আইটি ও প্রোগ্রামিং। এই অধ্যায়ে মোট 178টি প্রশ্ন আছে। নিচে প্রথম 10টি প্রশ্ন ও অপশন দেওয়া হলো; সঠিক উত্তর সার্ভারে যাচাই হয়।
এই অধ্যায়ে সব প্রশ্নে অনুশীলন করুন
Which concurrency pattern uses a channel to signal completion of a goroutine, allowing the main function to wait for it?
- Worker Pool
- Fan-out, Fan-in
- Done Channel (Completion Signal)
- Pipeline
উত্তর যাচাই করতে প্র্যাকটিসে যান।
In the 'Fan-out, Fan-in' pattern, what does 'Fan-out' refer to?
- Multiplexing multiple channels into a single channel
- Distributing work from one channel to multiple worker goroutines
- Closing a channel when all senders are done
- Buffering a channel to prevent blocking
উত্তর যাচাই করতে প্র্যাকটিসে যান।
What is the primary purpose of the `sync.WaitGroup` in Go concurrency patterns?
- To protect shared memory access (Mutual Exclusion)
- To wait for a collection of goroutines to finish execution
- To communicate data between goroutines via channels
- To limit the number of concurrent goroutines
উত্তর যাচাই করতে প্র্যাকটিসে যান।
Which pattern is best suited for limiting the number of concurrent operations (e.g., limiting API calls to 10 at a time)?
- Pipeline
- Worker Pool (using a buffered channel as a semaphore)
- Pub/Sub
- Generator
উত্তর যাচাই করতে প্র্যাকটিসে যান।
What characterizes a 'Pipeline' pattern in Go?
- Multiple stages connected by channels, where each stage is a goroutine processing data and passing to the next
- A single goroutine broadcasting messages to many subscribers
- A mutex protecting a shared map
- A function that returns a channel and spawns a goroutine to push data
উত্তর যাচাই করতে প্র্যাকটিসে যান।
How does the 'Generator' pattern differ from a standard function returning a slice?
- It returns a channel and produces values asynchronously in a goroutine
- It blocks the caller until all values are computed
- It uses a Mutex to protect the returned data
- It panics if the channel buffer is full
উত্তর যাচাই করতে প্র্যাকটিসে যান।
What is the correct way to implement 'Fan-in' (multiplexing) safely?
- Have multiple goroutines write to the same channel without synchronization
- Use a single goroutine to read from multiple input channels using a `select` statement
- Close all input channels immediately after starting workers
- Use a Mutex to lock the output channel before writing
উত্তর যাচাই করতে প্র্যাকটিসে যান।
In the 'Context' pattern for cancellation, what happens when `ctx.Done()` channel is closed?
- The program exits immediately
- All goroutines listening on that context should stop work and return
- The garbage collector runs
- A panic is triggered in the parent goroutine
উত্তর যাচাই করতে প্র্যাকটিসে যান।
Which pattern involves a goroutine that manages a specific piece of state (like a map or counter) and other goroutines communicate with it via channels to read/write that state?
- Mutex Guard
- Monitor Goroutine (or Actor Pattern)
- Pipeline
- Worker Pool
উত্তর যাচাই করতে প্র্যাকটিসে যান।
What is the idiomatic Go way to handle a 'Producer-Consumer' scenario where the producer might be faster than the consumer?
- Use an unbuffered channel to force synchronization (backpressure)
- Use a buffered channel to absorb bursts
- Use a Mutex and a slice
- Spawn unlimited goroutines for consumers
উত্তর যাচাই করতে প্র্যাকটিসে যান।