NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content

Quiz: Ruby

Ruby questions from real interviews as a quiz, with an explanation for every option.

25 questionsAll topicsRuby

Try it: 5 questions

Loading…

Sample questions

  1. What are Docker multi-stage builds used for?

    • To automatically run an application in several containers from a single Dockerfile.
    • To combine several Docker images into one while retaining all their files and dependencies.
    • To replace a dependency manager and install Ruby libraries without Bundler.
    • To build an application in one stage and copy only the runtime artifacts into the final image.
    Full answer
  2. Which statements correctly describe a Ruby Hash? Select all that apply.

    • Only symbols can be used as keys.
    • It preserves the order in which entries were added.
    • It stores key-value pairs, and values are accessed by key.
    • It provides fast average lookup by key.
    • It can only be accessed by numeric index, like an array.
    Full answer
  3. Which statement about PostgreSQL index types is correct?

    • Hash is general-purpose and used by default; B-tree is suited only to equality comparisons.
    • GIN is general-purpose and used by default; GiST is suited only to full-text search.
    • BRIN is general-purpose and used by default; SP-GiST is intended only for equality.
    • B-tree is general-purpose and used by default; Hash is suited to equality comparisons.
    Full answer
  4. What happens if Ruby evaluates MyString before a constant with that name has been defined?

    • It raises SyntaxError because constant names cannot contain String.
    • Ruby returns nil, as it does for a missing value.
    • Ruby automatically creates the string "MyString".
    • It raises NameError: uninitialized constant MyString.
    Full answer
  5. What is TCP/IP?

    • A routing protocol that chooses the shortest path for every packet.
    • A standard for physically connecting devices with Ethernet cables.
    • A data transfer protocol that always guarantees packets arrive in order.
    • A suite of network protocols for exchanging data between devices on the internet and local networks.
    Full answer
  6. In Ruby, what are the arguments passed when creating an instance with ClassName.new(...)?

    • Values passed to Class.new to declare class methods.
    • Values that the new method returns after creating an instance.
    • Local variables declared inside the class body.
    • Values that new passes to initialize to configure the new object.
    Full answer
  7. When does Rails create a controller instance, and how long is it used?

    • On the first visit to the controller; until the process restarts
    • After rendering the response; until the next request arrives
    • When the application starts; until it shuts down
    • After routing the request; to handle that request
    Full answer
  8. How do threads work with the Global VM Lock (GVL) in MRI Ruby?

    • Only one thread executes Ruby code at a time, but blocking I/O can release the GVL.
    • Each thread gets its own GVL and executes Ruby code in parallel.
    • The GVL prevents thread switching even while a thread waits for I/O.
    • MRI threads execute CPU-bound Ruby code in parallel, while the GVL limits only I/O.
    Full answer
  9. Which practices can help maintain database performance as the data volume grows? Select all that apply.

    • Normalize every table as much as possible because normalization always speeds up reads.
    • Create an index on every column regardless of the queries.
    • Analyze slow queries and their execution plans, for example with EXPLAIN.
    • Cache frequently requested data when that fits the data-freshness requirements.
    • Create indexes for fields frequently used in WHERE, JOIN, and ORDER BY.
    Full answer
  10. All else being equal, which usually has greater overhead: calling a block or lambda in the current Ruby process, or creating a separate process with Process.fork?

    • Creating a separate process
    • Calling a block
    • All three have roughly the same overhead
    • Calling a lambda
    Full answer