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

What is the purpose of baseUrl() in Retrofit.Builder?

In this round
  1. What is the purpose of baseUrl() in Retrofit.Builder?
  2. 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) } }
  3. Given `@POST("users") suspend fun createUser(@Body request: CreateUserRequest): User`, what HTTP method and content does this send?
  4. 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?
  5. What is a Call<T> return type in a Retrofit interface method used for, compared to a suspend function returning T directly?
  6. What happens if you add two different JSON converter factories to the same Retrofit.Builder without careful ordering?
  7. Why should HttpLoggingInterceptor.Level.BODY generally be disabled in production release builds?
  8. What does the @Body annotation do on a Retrofit method parameter?
  9. What does calling retrofit.create(UserApi::class.java) return?
  10. When a Retrofit interface method is declared as a suspend function, what does the caller need in order to invoke it?
  11. What is the role of a converter factory (like MoshiConverterFactory or GsonConverterFactory) added to Retrofit.Builder?
  12. Why does Retrofit require an OkHttpClient (directly or via a default one) under the hood?
Gaps to close?
Read the curated Retrofit notes — core concepts, patterns, interview prep.
Retrofit notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web