TOPIC
Programming languages
These are the same questions found in the library, grouped here by the capability each one mainly examines.
36 questions
A · Professional problem solving and implementation35
- How do you usually handle null values, empty strings, out-of-range access, and invalid input when writing code? Tell me about a time a missing up-front check caused a problem in testing or production, and what habit changed as a result.
- Implement a small cache that evicts the least recently used entry when full. What time cost does each operation need, and which tests do you write first?
- When writing code and reviewing it, what checks have become habit for avoiding performance problems such as querying a database inside a loop or holding large objects too long? How do you know they actually work?
- Implement a retry wrapper that retries by error type, supports a maximum attempt count, backoff, and cancellation, and does not overwhelm the dependency. Define the interface before coding, then explain how to make clocks, waits, and tests deterministic.
- A very large CSV must be validated without loading the whole file into memory. On malformed rows, the tool should report line numbers and continue checking. How would you design the parser interface?
- After multiple macro and code-generation expansions, compiler errors point only to generated files, leaving users unable to find the original code. How would you design diagnostics?
- Incremental compilation is fast, but changes to a shared header sometimes fail to rebuild all dependent targets. How would you find the dependency-tracking gap?
- A compiler upgrade changes struct layout or calling conventions, but some plugins are still built against the old ABI. How would you manage compatibility and migration?
- What happens between writing a line of code and the CPU running it? Pick a language you know and walk through the main stages.
- A complex form has field validation, cross-field rules, and server errors that overwrite one another during edits. How would you divide framework state from business state?
- After an async task starts, the caller immediately mutates an input object, and results sometimes change. How would you determine whether this is shared mutable state, copy semantics, or an ownership issue?
- Two usernames that look identical are treated as different, or distinct spellings are treated as the same. How would you analyze Unicode normalization and identity comparison?
- Two threads use a flag to signal that data is ready. Why might declaring only the flag atomic still fail to guarantee visibility of the data?
- Implement a map with concurrent reads and writes, per-entry expiration, and expired-entry cleanup. How would you define expiration semantics, synchronization boundaries, and deterministic tests?
- Implement deep equality for inputs that may contain nested arrays, shared references, and cycles. Define equality semantics first, then avoid infinite recursion and accidental confusion of reference structures.
- Implement a small task queue with concurrent workers, cancellation, and retries; tests must not depend on real sleeps. How would you design the scheduling interface and state transitions?
- Implement an incremental UTF-8 log parser that receives chunks which may split multibyte characters, reorder fields, contain multiple records, or include an exceptionally long line. Define parser state, error recovery, and memory limits, then implement repeatable core logic.
- A search field briefly freezes after typing even though the network request completes quickly. How would you use the event loop, task queues, and main-thread occupancy to explain it and locate long tasks?
- A service has stable average latency but periodic p99 spikes near allocation peaks. How would you determine whether garbage collection is responsible and distinguish it from other pauses?
- A request starts several async tasks. After the client disconnects or the request times out, some downstream work still uses threads and connections. How would you propagate cancellation and release those resources?
- A set of asynchronous callbacks prints the same loop variable or a value different from what was expected. Using a language you know, explain binding and closure capture, then give a verifiable correction.
- A compiler may reorder or eliminate code. Which program behavior may it change, and which externally observable behavior must it preserve? Explain with a concurrency or I/O example.
- An object overrides equality but keeps the default hash implementation, causing failed lookups in a hash collection. Explain the equality/hash contract and how you would test it.
- A library’s generic type information is unavailable at runtime, causing reflection or serialization to behave unexpectedly. Explain which runtime behaviors erasure affects and how you might redesign the API.
- Given a set of records that may exceed memory capacity, process them in batches while allowing the caller to cancel. Describe or implement an interface that bounds memory, locates errors, and starts no new batch after cancellation.
- Several callers read a configuration file whose fields keep growing; older fields may be absent, and new versions must allow unknown extension fields. How would you design a parsing interface so callers can understand defaults, validation errors, and backward-compatibility behavior?
- The input contains time intervals that may overlap or touch, and callers need to find records covering a given instant. Describe or implement a merge and query strategy, including whether endpoints are inclusive.
- An API adds a new state, but older clients may not recognize it; some must still display the record, while critical operations must reject unknown states. How would you design parsing and defaults so an unknown value is not mistaken for a valid state?
- Events arrive as a stream, and some duplicates may be hours apart. Memory must remain bounded, and deduplication must survive process restarts. How would you define the time window, persistent state, and false-positive boundaries?
- A backend API generates TypeScript, Java, and Swift SDKs, but nullable types, enums, and error models are drifting across languages. How would you design the contract source, generation process, and cross-language compatibility tests?
- A model has streamed partial output to a user when the connection drops or a safety check fails; the client may make the answer look complete. How would you design completion markers, withdrawal or explanatory notices, and retry behavior?
- A service accumulates monetary values with floating-point numbers, and reconciliation drift grows over time. How would you identify the source and redesign calculations while migrating historical data?
- Given many timestamped records, return the top K by score and preserve earlier items on ties. How would you implement it and analyze edge cases?
- Several sources are individually time-sorted, but total data exceeds memory. Explain how to merge output and handle a source that slows or disconnects temporarily.
- You need retries and timeouts for an async function. On final failure, callers still need each attempt’s error and whether side effects occurred. How would you design the result?
No questions in this section match your target. ·