Android Hilt Interview Questions
Dependency injection fundamentals, scopes, and modules.
50 questions in this topic · 8 sample questions below
Practice Hilt in the quiz engine
Sample questions
What is the fundamental difference between Dependency Injection and the Service Locator pattern?
Why: With DI, dependencies are supplied externally so the class does not know where they come from; with a service locator the class actively pulls from a registry, hiding its dependencies. They are not the same pattern, and the constructor-versus-field distinction is orthogonal to both.
Why must Hilt use field injection for Activities and Fragments rather than constructor injection?
Why: The OS constructs Activities and Fragments through their no-arg constructors, so Hilt has no chance to pass dependencies in and must inject into fields after creation. Constructor injection is fully supported by Dagger elsewhere; the limitation is purely that the framework owns instantiation.
A key advantage of Hilt and Dagger over Koin is that they:
Why: Hilt and Dagger build and verify the object graph during compilation, turning missing bindings into build errors rather than crashes. Koin resolves at runtime, so those same problems surface as exceptions when the code path executes, not at compile time.
When does a missing dependency typically surface in Koin versus Hilt?
Why: Koin uses runtime resolution, so an unresolved definition throws a NoBeanDefFoundException only when that code runs. Hilt's annotation processor detects the same gap during the build, failing compilation before the app ever launches.
What is the primary difference between @Binds and @Provides in a Hilt module?
Why: @Binds is an abstract method that simply maps an interface to an implementation Hilt already knows how to construct, so no factory implementation is generated. @Provides requires a concrete method body and produces additional generated code, and the two are not interchangeable in behavior or efficiency.
Why can a @Binds method be abstract while a @Provides method cannot?
Why: @Binds merely declares that requests for the supertype should be satisfied by an already-injectable subtype, information Hilt encodes without invoking any code. @Provides must actually construct or obtain the instance, which requires a concrete body; it is not deprecated.
You depend on a Retrofit interface from a third-party library and cannot annotate its constructor. How do you make it injectable in Hilt?
Why: For types you do not own and cannot add @Inject to, @Provides lets you supply a constructed instance through a method you control. @Binds cannot be used because Hilt still would not know how to construct the underlying implementation, and there is no reflection-based @Inject injection.
By default, how many instances does Hilt provide when an unscoped binding is requested multiple times?
Why: Unscoped bindings are not cached, so Hilt creates a fresh instance for each injection request. Sharing a single instance requires an explicit scope annotation such as @Singleton; unscoped is the default and is perfectly valid.
Practice all 50 Hilt questions
These 8 are a sample. The full Hilt bank is scored, tracks your progress, and explains every answer.
More Android interview topics
- 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 Retrofit 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