Java Developer Interview Question

Your service calls a third party API that occasionally becomes slow. How do you configure the client so that does not take you down?

What the interviewer is probing, how to structure your answer, and a spoken example you can adapt.

Quick answer

Set explicit connect and read timeouts on the client, because several Java HTTP clients default to waiting indefinitely, and add an overall request timeout. Bound the connection pool for that host, retry only idempotent calls with backoff and jitter, and add a circuit breaker so sustained failures fail fast. Decide the fallback ahead of time: a cached value, a degraded response, or a clear error rather than a hanging request.

Why interviewers ask this

The interviewer wants to know whether you have been burned by a default configuration. Naming that some clients wait forever, and that a shared connection pool plus a slow host is how one dependency stalls unrelated endpoints, shows operational experience. Follow ups probe how you would test the failure, which usually means a fault injection proxy or a stub that delays responses.

How to structure your answer

  • Set every timeout explicitly and never trust defaults.
  • Isolate the dependency with its own bounded connection pool.
  • Add retries only where safe, with backoff and a circuit breaker.
  • Define and implement the degraded behavior.

Example answer

Spoken example, first person

I start from the assumption that the defaults are wrong, because several clients will happily wait forever on a read, and that is exactly how a slow dependency turns into every thread in my service being parked. So connect timeout short, read timeout based on their actual latency distribution rather than a round number, and an overall request timeout on top since retries and redirects can stack. Then isolation: that dependency gets its own connection pool with a maximum, so when it degrades it cannot consume all the capacity that other calls need. Retries only on idempotent operations, capped at two attempts with exponential backoff and jitter, and a circuit breaker in front so that once the error rate crosses a threshold I fail immediately for a cooldown rather than piling requests onto something already struggling. The last piece is what the user gets, decided in advance. On a shipping rates integration we served cached rates with a staleness marker rather than failing checkout, and that turned a vendor outage into a minor accuracy problem instead of lost orders. I test it with a proxy that injects delays.

Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.

See how it works

Follow-up questions to expect

  • How would you pick the read timeout value?
  • What is bulkheading, and how does it apply here?
  • How do you test that your fallback path actually works?

Related java developer questions

Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.

Predict my questions

Rehearse the hard questions before they are asked

Practise with a live copilot, then walk in ready. A $29 Session Pass gets you through the interview with no subscription and no lock-in.

Get GhostPilot