readyforhires

Advanced Go test (Advanced)

40 questions · 40 minutes · ₹6

Runtime, scheduler, memory, generics and high-performance services.

Take the Advanced Go test

Prices in Indian rupees (INR).

What it covers

Interview format

Earn a certificate

The Advanced Go test is one of the 6 tests of the Go Backend Developer: Advanced learning path. Pass it and the other 5 tests at 70% or more and readyforhires issues you a verifiable certificate in your name, with its own code and verify link to share or add to LinkedIn.

Sample learning path certificate for Go Backend Developer: Advanced, made out to “Your name” and marked SAMPLE
Pass with 70% or more to earn a verifiable certificate. This is a sample: yours carries your name, the date you earned it and its own verify code.

Sample questions

5 sample questions from the Advanced Go test, with the answers. Samples are taken out of the live test, so you will not meet these when you sit it.

  1. A developer is experiencing a memory leak in a Go application and wants to use the `pprof` tool to identify the issue. Which of the following options correctly uses the pprof tool to analyze memory allocation and identify retained objects?

    1. Use `go tool pprof -inuse_space` to analyze CPU usage during memory-intensive operations.
    2. Use `go tool pprof -alloc_space` to analyze memory allocations and identify objects that are being retained unnecessarily.
    3. Use `go build -gcflags=-m` to optimize memory allocation in the runtime.
    4. Use `go test -race` to detect memory leaks caused by concurrent access.

    Answer: B. Use `go tool pprof -alloc_space` to analyze memory allocations and identify objects that are being retained unnecessarily.

    The `go tool pprof -alloc_space` command is used to analyze memory allocations and track how much memory is being allocated over time. This helps identify memory leaks or unnecessary allocations. Other options are either incorrect or not directly related to memory profiling.

  2. What is the correct behavior when GOMAXPROCS is set to 1 in a Go program?

    1. Setting GOMAXPROCS to 1 prevents the scheduler from switching between goroutines.
    2. Setting GOMAXPROCS to 1 allows the program to use all available CPU cores.
    3. Setting GOMAXPROCS to 1 ensures that all goroutines run sequentially without any concurrency.
    4. Setting GOMAXPROCS to 1 limits the program to using a single CPU core, but does not stop the scheduler from switching between goroutines.

    Answer: D. Setting GOMAXPROCS to 1 limits the program to using a single CPU core, but does not stop the scheduler from switching between goroutines.

    The GOMAXPROCS environment variable determines the maximum number of CPU cores that can be used by the Go runtime. When set to 1, the scheduler can still switch between goroutines, but only one core is utilized. This means that even though goroutines can be scheduled, they will not run in parallel on multiple cores. The other options incorrectly describe the behavior of GOMAXPROCS.

  3. Which of the following is the correct approach to mutex lock ordering when managing concurrent access to shared resources, and why?

    1. Using a single global mutex for all operations, as it reduces contention and avoids deadlocks.
    2. Using multiple fine-grained locks with strict ordering, as it always reduces contention and avoids deadlocks.
    3. Using a single global mutex for all operations, as it ensures consistency but can lead to contention.
    4. Using multiple fine-grained locks with no ordering, as it reduces contention but may lead to deadlocks.

    Answer: C. Using a single global mutex for all operations, as it ensures consistency but can lead to contention.

    Mutex lock ordering refers to the strategy of acquiring and releasing locks in a way that avoids deadlocks and minimizes contention. Using a single global mutex for all operations ensures consistency by preventing concurrent modifications to shared resources. However, this approach can lead to high contention, especially in systems with many concurrent operations. In contrast, using multiple fine-grained locks (e.g., per-object or per-data structure) can reduce contention but requires careful ordering to avoid deadlocks. The choice depends on the specific use case and the trade-off between consistency and performance.

  4. Which of the following accurately describes the behavior of the Go runtime scheduler with respect to distributing goroutines across CPU cores?

    1. The Go scheduler assigns all goroutines to a single CPU core for performance reasons.
    2. The Go scheduler uses a round-robin algorithm to assign goroutines to threads.
    3. The Go scheduler does not support fair distribution of goroutines across CPU cores.
    4. The runtime scheduler in Go ensures that goroutines are distributed evenly across available CPU cores.

    Answer: D. The runtime scheduler in Go ensures that goroutines are distributed evenly across available CPU cores.

    The Go runtime scheduler is designed to distribute goroutines evenly across available CPU cores, maximizing parallelism and resource utilization. This is achieved by maintaining a global queue of goroutines and assigning them to idle threads. Other options may be misleading or incorrect based on the actual behavior of the Go scheduler.

  5. What happens when a goroutine sends a value on a channel, and there is no corresponding receive operation on that channel?

    1. The send operation blocks until the receiver is ready to receive the value.
    2. The send operation will not block and will immediately return.
    3. The send operation will cause a runtime panic if the receiver is not ready.
    4. The send operation will automatically time out after a fixed period.

    Answer: A. The send operation blocks until the receiver is ready to receive the value.

    In Go, when a goroutine sends a value on a channel, the send operation will block until there is a corresponding receive operation on the same channel. This behavior ensures that data is only transferred when both the sender and receiver are ready, preventing data loss and ensuring synchronization.

Frequently asked questions

How many questions are in the Advanced Go test?
40 questions (24 multiple choice, 12 multi-answer, 4 predict-the-output), with 40 minutes to answer them.
What does the Advanced Go test cover?
Scheduler and runtime, Escape analysis and GC, Generics, Concurrency patterns and race detection, Profiling with pprof.
Is the Advanced Go test free?
It costs ₹6 a test, paid per test with no subscription. Prices in Indian rupees (INR).
What level is the Advanced Go test?
Advanced, in Backend.

More Backend tests

Roles that test these skills

Companies that test these skills

All practice tests · All Backend tests

Last updated