Android Retrofit Interview Questions
Networking, interceptors, and error handling.
50 questions in this topic · 8 sample questions below
Practice Retrofit in the quiz engine
Sample questions
In OkHttp, what is the key difference between an application interceptor and a network interceptor?
Why: Application interceptors run once per call regardless of caching or redirects; network interceptors sit closer to the wire and are skipped entirely on a full cache hit. The claim that a network interceptor sees cache hits is the classic misconception.
Why is OkHttp's Authenticator preferred over a plain interceptor for OAuth token refresh?
Why: Authenticator is a reactive challenge handler triggered on 401/407 that returns a new authenticated request, and OkHttp limits its retries. It does not run preemptively, and it does not deduplicate concurrent refreshes for you, so single-flight synchronization is still your responsibility.
Several requests get 401 at once and each triggers a token refresh. What is the correct single-flight strategy?
Why: You synchronize the refresh and re-check whether the token already changed before refreshing, so only one network refresh happens and the rest reuse the result. OkHttp does not merge concurrent refreshes, and timeouts or pool tweaks do not address the race.
Does Retrofit automatically retry a request that failed with an IOException?
Why: Retrofit does not implement retries; a failed call surfaces the exception to you. OkHttp only transparently recovers from certain connection-level failures when retryOnConnectionFailure is on, which is not the same as retrying application errors.
With a Retrofit suspend function returning a plain type like User, what happens on a non-2xx HTTP response?
Why: A suspend function returning a bare body type throws HttpException on non-2xx, while network failures throw IOException. Returning null or an empty object would require you to wrap the return in Response or Result yourself.
When a Retrofit call returns HTTP 422 with a JSON error body, how do you read that body?
Why: On an unsuccessful response the payload is in errorBody(), not body(), and you can parse it with a matching converter. body() is null for non-2xx, and the exception message does not contain the parsed error object.
Why is an HTTP POST response generally not served from the OkHttp cache?
Why: HTTP caching is defined around safe, idempotent methods; POST responses are not cached because they typically represent state changes. It is a protocol semantics decision, not a size limit or a header Retrofit injects.
How does a conditional GET with an ETag reduce bandwidth?
Why: The stored ETag is echoed in If-None-Match; a 304 tells the client its cached body is still valid, avoiding retransmission. If-Modified-Since is the date-based validator and is not the ETag mechanism.
Practice all 50 Retrofit questions
These 8 are a sample. The full Retrofit bank is scored, tracks your progress, and explains every answer.
More Android interview topics
- Android Hilt interview questions
- Android Coroutines & Flow interview questions
- Android Room interview questions
- Android Design Patterns interview questions
- Android Mobile System Design interview questions
- Android Coding Interview Patterns interview questions
- Android NDK interview questions
- Android Sensors interview questions
- Android Security interview questions
- Android Jetpack Compose interview questions
- Android Canvas & Animation interview questions
- Android CI/CD interview questions
- Android Git interview questions
- Android Unit Testing interview questions
- Android Kotlin interview questions
- Android Architecture interview questions
- Android Android Framework interview questions
- Android Kotlin Multiplatform interview questions
- Android WorkManager & Background interview questions
- Android Performance & Memory interview questions