Eduversity.bd — Learn with Us, Achieve Your Dreams

গো (Go) — MCQ প্রশ্ন

আইটি ও প্রোগ্রামিং MCQ (ওপেন) · আইটি ও প্রোগ্রামিং। এই অধ্যায়ে মোট 178টি প্রশ্ন আছে। নিচে প্রথম 10টি প্রশ্ন ও অপশন দেওয়া হলো; সঠিক উত্তর সার্ভারে যাচাই হয়।

এই অধ্যায়ে সব প্রশ্নে অনুশীলন করুন

  1. Which concurrency pattern uses a channel to signal completion of a goroutine, allowing the main function to wait for it?

    1. Worker Pool
    2. Fan-out, Fan-in
    3. Done Channel (Completion Signal)
    4. Pipeline

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  2. In the 'Fan-out, Fan-in' pattern, what does 'Fan-out' refer to?

    1. Multiplexing multiple channels into a single channel
    2. Distributing work from one channel to multiple worker goroutines
    3. Closing a channel when all senders are done
    4. Buffering a channel to prevent blocking

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  3. What is the primary purpose of the `sync.WaitGroup` in Go concurrency patterns?

    1. To protect shared memory access (Mutual Exclusion)
    2. To wait for a collection of goroutines to finish execution
    3. To communicate data between goroutines via channels
    4. To limit the number of concurrent goroutines

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  4. Which pattern is best suited for limiting the number of concurrent operations (e.g., limiting API calls to 10 at a time)?

    1. Pipeline
    2. Worker Pool (using a buffered channel as a semaphore)
    3. Pub/Sub
    4. Generator

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  5. What characterizes a 'Pipeline' pattern in Go?

    1. Multiple stages connected by channels, where each stage is a goroutine processing data and passing to the next
    2. A single goroutine broadcasting messages to many subscribers
    3. A mutex protecting a shared map
    4. A function that returns a channel and spawns a goroutine to push data

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  6. How does the 'Generator' pattern differ from a standard function returning a slice?

    1. It returns a channel and produces values asynchronously in a goroutine
    2. It blocks the caller until all values are computed
    3. It uses a Mutex to protect the returned data
    4. It panics if the channel buffer is full

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  7. What is the correct way to implement 'Fan-in' (multiplexing) safely?

    1. Have multiple goroutines write to the same channel without synchronization
    2. Use a single goroutine to read from multiple input channels using a `select` statement
    3. Close all input channels immediately after starting workers
    4. Use a Mutex to lock the output channel before writing

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  8. In the 'Context' pattern for cancellation, what happens when `ctx.Done()` channel is closed?

    1. The program exits immediately
    2. All goroutines listening on that context should stop work and return
    3. The garbage collector runs
    4. A panic is triggered in the parent goroutine

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  9. 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?

    1. Mutex Guard
    2. Monitor Goroutine (or Actor Pattern)
    3. Pipeline
    4. Worker Pool

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

  10. What is the idiomatic Go way to handle a 'Producer-Consumer' scenario where the producer might be faster than the consumer?

    1. Use an unbuffered channel to force synchronization (backpressure)
    2. Use a buffered channel to absorb bursts
    3. Use a Mutex and a slice
    4. Spawn unlimited goroutines for consumers

    উত্তর যাচাই করতে প্র্যাকটিসে যান।

← আগের অধ্যায়পরের অধ্যায় →