Android Design Patterns Interview Questions
Factory, Singleton, Observer, and more.
50 questions in this topic · 8 sample questions below
Practice Design Patterns in the quiz engine
Sample questions
In Kotlin, what is the most idiomatic way to implement the Singleton pattern?
Why: A Kotlin object declaration creates a single, thread-safely instantiated instance managed by the JVM class loader. The manual double-checked-locking approach is the Java idiom and is unnecessary boilerplate in Kotlin.
A colleague claims a Kotlin object is not a real Singleton because it can be instantiated reflectively. What is the accurate assessment?
Why: An object declaration compiles to a class with a private constructor and a single INSTANCE field created safely by the JVM on first class-load. The reflection claim is a general Java caveat, not something that invalidates object as the standard Singleton.
Why is double-checked locking largely irrelevant when using a Kotlin object for lazy singleton initialization?
Why: The class-initialization lock provided by the JVM guarantees a single, safe initialization the first time the object is referenced. Objects are not eagerly created at startup; they are initialized on first access.
You need a value computed once, lazily, and safely across threads inside a class. Which is the idiomatic Kotlin choice?
Why: Delegated lazy defaults to SYNCHRONIZED mode, computing the value once even under concurrent access. lateinit cannot be used with val or primitive types and provides no lazy computation or thread safety.
Which statement about LazyThreadSafetyMode.PUBLICATION is correct?
Why: PUBLICATION allows several threads to race through the initializer, but a compare-and-set ensures only the first successfully published value is retained. SYNCHRONIZED is the mode that guarantees a single execution while blocking others.
The Builder pattern is often said to be redundant in Kotlin. When is a Builder still genuinely useful over named/default arguments?
Why: Builders remain valuable for Java interop, staged/step builders, and accumulating state across calls before a final build with validation. The blanket claim that default args always replace Builder ignores these interop and incremental-construction cases.
Which Kotlin feature most directly replaces a hand-written Prototype pattern for immutable data classes?
Why: data class copy() produces a new instance with selected properties overridden, which is exactly the intent of Prototype for value objects. Cloneable/clone() is the Java mechanism and is discouraged in idiomatic Kotlin.
A key caveat when relying on data class copy() as a Prototype is:
Why: copy() copies references, so a mutable list or object held by the original is shared with the copy, risking aliasing bugs. It does not deep-clone, which is the classic Prototype pitfall.
Practice all 50 Design Patterns questions
These 8 are a sample. The full Design Patterns bank is scored, tracks your progress, and explains every answer.
More Android interview topics
- Android Hilt interview questions
- Android Coroutines & Flow interview questions
- Android Room 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