All bites
The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.
4330 bites
Page 201

Model a Room one-to-many Playlist-to-Song relationship
Tests Room relational modeling. Strong answer: Song foreign key, @Embedded Playlist with @Relation to List<Song>, DAO wrapped in @Transaction. Red flag: embedding songs in Playlist or skipping @Transaction, which causes N+1 queries.

Preferences vs Proto DataStore: when is Proto significantly better?
This tests type safety and schema trade-offs. A strong answer contrasts Preferences key-value pairs with Proto typed protobuf schemas, then names nested settings or migration needs as the Proto win. A red flag is recommending Proto for a single boolean.

Room DAO: Flow<List<User>> vs suspend fun getUsers(): List<User>
This tests reactivity versus one-shot queries in Room and coroutines. Flow emits on every table change on Room's dispatcher, while suspend returns a single snapshot requiring manual refresh.

How would you implement a robust offline-first repository?
Tests single-source-of-truth discipline and network-local sync. Outline a Room repository with Flow, background refresh, disk persistence, immediate local emission, and conflict resolution with retry.
How would you use Retrofit to GET /posts/{id} and key components?
This checks your understanding of Retrofit's three-layer setup. You need a data class for JSON parsing, an interface with @GET and @Path, and a Retrofit.Builder with baseUrl and a converter.
How do you configure Moshi or Kotlinx.serialization for JSON key mismatches?
This tests library-specific field-mapping annotations. For Kotlinx.serialization use @SerialName with the JSON key; for Moshi use @Json with the name parameter. A red flag is confusing the two or using manual mapping instead of the built-in decorator.
Explain Retrofit Interceptors and write a static API key interceptor
Tests OkHttp interception and application versus network scope. Strong answers build a new request adding X-Api-Key via newBuilder and chain.proceed; contrast addInterceptor once versus addNetworkInterceptor per hop.

How do you differentiate network and server errors in suspend functions?
Catch IOException for connectivity and HttpException for HTTP errors; wrap in a sealed Result.

How do you upload a file with text data in Retrofit?
Tests multipart uploads versus JSON bodies. Strong answer: @Multipart, @POST, @Part; file as MultipartBody.Part and text as RequestBody; avoid @Field. Red flag: suggesting @Body with a data class.
Parse polymorphic media JSON with Kotlin sealed classes and custom serializers
Sealed Media with Image and Video; use Moshi Factory or kotlinx.serialization keyed on the type field.
Configure OkHttp Cache for Retrofit and force network requests
This tests HTTP caching semantics in mobile networking. A strong answer covers Cache setup with a 50 MiB directory, server Cache-Control driving expiration, and CacheControl.FORCE_NETWORK to bypass.

What is Dependency Injection and Hilt's benefit over manual instantiation?
Tests your grasp of inversion of control and why frameworks matter. A good answer defines DI as supplying dependencies from outside, states Hilt automates object graph creation and scoping, and notes manual instantiation scatters construction logic.

How do you inject UserRepository into a ViewModel with Hilt?
Tests Hilt constructor injection for classes you own. Annotate UserRepository's constructor with @Inject so Hilt auto-provides it to consumers like a @HiltViewModel. Red flag: using a @Provides module for a class you control.

Explain Hilt scoping: @Singleton vs @ActivityRetainedScoped
Tests Hilt component lifecycles. Answer: @Singleton lives for the app process; @ActivityRetainedScoped survives config changes via ActivityRetainedComponent but dies when the activity finishes.

How do you inject two different OkHttpClient instances with Hilt?
Tests Hilt qualifiers for same-type bindings. Answer: define a custom @Qualifier (or @Named), annotate two @Provides methods and the injection site. Red flag: manual client creation or subclassing OkHttpClient instead of qualifying the binding.

Functional difference between @Binds and @Provides in Hilt
Tests if you understand Hilt code generation tradeoffs. @Binds wires an existing injectable implementation to an interface with less overhead; @Provides constructs instances manually.

How would you access a Hilt dependency in a non-injectable ContentProvider?
Tests Hilt's escape hatch for framework classes. Strong answer: define an EntryPoint in SingletonComponent, expose the dependency, and retrieve it with EntryPointAccessors.fromApplication. Red flag: field injection or manual static singletons.

Replace a production NetworkService with a fake in Hilt instrumented tests
Tests whether you know Hilt test overrides beyond basic DI. A strong answer covers @BindValue for field-level fakes and @TestInstallIn or @UninstallModules for module swaps.

Describe Hilt's component hierarchy and scope injection rules
Tests whether you understand Hilt's generated component tree and scoping rules. A strong answer lists the hierarchy, explains parent-outlives-child semantics, and states that ActivityScoped-into-Singleton injection fails at compile time.

How do you make a network request in an Activity using coroutines?
This tests main thread safety and coroutine dispatchers. A strong answer cites NetworkOnMainThreadException, uses lifecycleScope, and switches to Dispatchers.IO. Red flag: suggesting Dispatchers.Main for the network call or omitting the exception entirely.