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