All quizzes
Free quiz · 26 questions in the bank

Retrofit quiz

Test your Retrofit knowledge with a free interactive quiz — 26 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

If baseUrl is set to "https://api.example.com/v1/" and an endpoint is declared as `@GET("/users")` (note the leading slash), what typically happens to the final URL?

In this round
  1. If baseUrl is set to "https://api.example.com/v1/" and an endpoint is declared as `@GET("/users")` (note the leading slash), what typically happens to the final URL?
  2. Why does Retrofit require an OkHttpClient (directly or via a default one) under the hood?
  3. What is a Call<T> return type in a Retrofit interface method used for, compared to a suspend function returning T directly?
  4. Why is it recommended to build a single shared Retrofit/OkHttpClient instance for an app instead of creating a new one for every request?
  5. What happens if you add two different JSON converter factories to the same Retrofit.Builder without careful ordering?
  6. Why is it useful to wrap Retrofit calls in a helper like a sealed ApiResult (Success/Error) type rather than letting each call site handle try/catch individually?
  7. Why should HttpLoggingInterceptor.Level.BODY generally be disabled in production release builds?
  8. Why might a Kotlin-first project choose Moshi over Gson as its Retrofit converter?
  9. A Retrofit interface method is declared as `suspend fun getUser(id: String): User`. If the server responds with HTTP 404, what happens?
  10. What Retrofit feature would you reach for to support returning a different asynchronous wrapper type (e.g. RxJava's Single<T>) instead of Call<T> or a suspend function?
  11. What is an OkHttp interceptor, in the context of Retrofit?
  12. What does the following interceptor do? class AuthInterceptor(val tokenProvider: () -> String?) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val token = tokenProvider() ?: return chain.proceed(chain.request()) val req = chain.request().newBuilder().header("Authorization", "Bearer $token").build() return chain.proceed(req) } }
Gaps to close?
Read the curated Retrofit notes — core concepts, patterns, interview prep.
Retrofit notes

More quizzes

.NETAccessibilityAgile MethodologyAlertmanagerAlgorithmsAndroid