REST
Q1: What is REST?
A: REST is an architectural style for building networked applications that uses stateless
communication, typically over HTTP, with resources identified by URIs and manipulated via
standard HTTP methods.
Q2: Is REST a protocol?
A: No — it’s a set of architectural constraints, not a protocol.
Q3: What does “stateless” mean in REST?
A: The server does not store any client session data between requests; all necessary info must
be sent in each request.
Q4: What is a resource in REST?
A: Any identifiable entity in the system, represented via a URI (e.g., /products/42).
Q5: What’s the difference between REST and HTTP?
A: HTTP is a protocol; REST is an architectural style that often uses HTTP as its transport.
Q1: What’s the difference between Accept and Content-Type?
A: Accept = what format client wants in the response.
Content-Type = format of the request body being sent.
Q2: What is the purpose of the Authorization header?
A: It carries credentials (like API keys, JWT tokens) for authentication.
Q3: Can GET requests have a body?
A: Technically allowed by HTTP spec, but discouraged — most servers ignore it.
Q4: Why is HTTP often used for REST?
A: It provides standard methods, status codes, and headers that map well to REST’s resource
operations.
Q1: Should URIs contain actions like /getUser?
A: No. Use HTTP methods to represent actions, and URIs to represent resources.
Q2: When to use query parameters vs path parameters?
A: Path params for identifying resources; query params for filtering, sorting, pagination.
Q3: Why avoid file extensions in URIs?
A: To decouple representation from resource — use Accept header for format negotiation.
Q4: How do you represent relationships?
A: Use nested paths like /users/{id}/orders for containment relationships.
MVVM
Q: What problem does MVVM solve compared to MVC or MVP?
A: It reduces coupling between UI and business logic, improves testability, and supports reactive
state updates. Unlike MVC/MVP, the ViewModel is lifecycle-aware and survives configuration
changes (in Android).
Q: Why is the View passive in MVVM?
A: The View only renders UI based on state and forwards user actions; it doesn’t contain
business logic.
ViewModel & State
1. Q: What is the MAIN ROLE of a ViewModel?
A: To hold UI STATE and LOGIC independent of the View’s lifecycle.
2. Q: Why use VIEWMODEL instead of keeping state in an Activity?
A: It SURVIVES CONFIGURATION CHANGES and avoids MEMORY LEAKS.
3. Q: What’s the difference between VIEWMODEL and ANDROIDVIEWMODEL?
A: AndroidViewModel has APPLICATION CONTEXT access; ViewModel doesn’t.
4. Q: How does ViewModel handle PROCESS DEATH?
A: By combining with SAVEDSTATEHANDLE or persistent storage.
5. Q: How do you avoid MUTABLE STATE LEAKS?
A: Expose IMMUTABLE LiveData/StateFlow to the View.
6. Q: When does onCleared() get called?
A: When the ViewModel is removed from VIEWMODELSTORE (e.g., Activity finish).
7. Q: What happens to ViewModel after a SCREEN ROTATION?
A: It is REUSED, so UI state is preserved.
8. Q: How do you pass ARGUMENTS into a ViewModel?
A: Use SAVEDSTATEHANDLE with Navigation arguments or a FACTORY.
State & Events
1. Q: What is STATE in MVVM?
A: All UI data at a moment, held in ViewModel, immutable to the View.
2. Q: Why use IMMUTABLE STATE?
A: Prevents accidental changes from the View, improves predictability.
3. Q: When to use LIVE DATA vs STATEFLOW?
A: LiveData for lifecycle-aware XML UI; StateFlow for Compose or explicit lifecycle
handling.
4. Q: What is a SHARED FLOW used for?
A: Emitting one-time events like navigation or snackbars.
5. Q: How to prevent EVENT RE-EMISSION after rotation?
A: Use SharedFlow, Channel, or event wrappers instead of LiveData.
6. Q: What is the SINGLE SOURCE OF TRUTH in MVVM?
A: ViewModel’s UI state variable.
Repository Pattern
1. Q: What is the REPOSITORY PATTERN?
A: An abstraction layer over data sources, providing a clean API to the ViewModel.
2. Q: Why have MAPPERS between DTO and Domain?
A: To keep UI/business logic independent of API schema changes.
3. Q: Where does ROOM fit in MVVM?
A: In the data layer, accessed via the Repository.
4. Q: How to implement OFFLINE SUPPORT?
A: Use caching with a local DB and sync logic in Repository.
5. Q: Why not call API directly from ViewModel?
A: Breaks separation of concerns and makes testing harder.
6. Q: How to handle ERRORS in Repository?
A: Wrap results in Result or sealed class for success/error.
Coroutines
1. Q: What is VIEWMODELSCOPE?
A: A coroutine scope tied to ViewModel lifecycle; cancels coroutines on onCleared().
2. Q: When to use DISPATCHERS.IO?
A: For blocking I/O like DB or network calls.
3. Q: Why use STRUCTURED CONCURRENCY?
A: Ensures predictable coroutine cancellation and resource cleanup.
4. Q: How to handle EXCEPTIONS in coroutines?
A: Use try/catch, CoroutineExceptionHandler, or sealed results.
5. Q: What’s the difference between LAUNCH and ASYNC?
A: launch returns Job (fire-and-forget), async returns Deferred (await result).
Dependency Injection (DI) & Hilt
1. Q: What is DEPENDENCY INJECTION?
A: A design pattern where dependencies are provided rather than created by the class
itself.
2. Q: Why use HILT over manual DI?
A: Handles object creation, scoping, and lifecycle automatically.
3. Q: What does @HILTVIEWMODEL do?
A: Tells Hilt to manage ViewModel creation and inject dependencies into its constructor.
4. Q: Difference between @SINGLETON and @VIEWMODELSCOPED?
A: Singleton lives for the app lifecycle, ViewModelScoped lives only while the
ViewModel exists.
1.
KOTLIN
1. What is the difference between VAL and VAR in Kotlin?
VAL is immutable (cannot be reassigned after initialization), while VAR is mutable and
can be reassigned.
2. What does TYPE INFERENCE mean in Kotlin?
It means the compiler automatically determines the variable’s type without you explicitly
declaring it.
3. What is a NULLABLE TYPE in Kotlin?
A type that is explicitly marked with ? and can hold a null value.
4. What does the SAFE CALL operator do?
It calls a property or method only if the receiver is not null, otherwise returns null.
5. What is the ELVIS OPERATOR used for?
It provides a default value if the left-hand expression is null.
6. What happens if you use the DOUBLE BANG (!!) on a null value?
It throws a NullPointerException at runtime.
7. What is the difference between LATEINIT and LAZY?
LATEINIT is for mutable vars initialized later, while LAZY is for read-only vals initialized
on first access.
8. What does HIGHER-ORDER FUNCTION mean in Kotlin?
A function that takes another function as a parameter or returns one.
9. What is a LAMBDA in Kotlin?
An anonymous function that can be stored in a variable or passed to another function.
10.What are EXTENSION FUNCTIONS used for?
To add new functions to existing classes without modifying their source code.
11.What is the difference between IMMUTABLE and MUTABLE collections in Kotlin?
Immutable collections cannot be modified after creation, mutable collections can be
changed.
12.What does the MAP function do?
It transforms each element of a collection and returns a new collection.
13.What is the purpose of ASSEQUENCE in Kotlin?
It turns a collection into a lazy sequence where operations are evaluated on demand.
14.What is the difference between FOREACH and MAP?
FOREACH is used for side effects and returns Unit, MAP returns a new collection.
15.What is the difference between PRIMARY and SECONDARY constructors?
The PRIMARY constructor is declared in the class header, while SECONDARY
constructors are inside the class body.
16.What does the OBJECT keyword create in Kotlin?
It creates a singleton instance of a class.
17.What is a COMPANION OBJECT in Kotlin?
A singleton associated with a class for holding static-like members.
18.
DATA CLASSES
1. What is the main purpose of a DATA CLASS in Kotlin?
To hold data and automatically generate boilerplate methods like
equals, hashCode, and toString.
2. What is the COPY FUNCTION in a data class used for?
To create a new instance by changing only some properties.
3. What is DESTRUCTURING in Kotlin data classes?
Extracting properties into separate variables using componentN()
functions.
4. Can a DATA CLASS be abstract or open?
No, a data class cannot be abstract, open, sealed, or inner.
5. What happens if a DATA CLASS has mutable properties?
They can still change, so immutability is not guaranteed.
6. What is the difference between STRUCTURAL EQUALITY and
REFERENTIAL EQUALITY in Kotlin?
Structural equality (==) checks if values are the same using equals(),
while referential equality (===) checks if both variables point to the
same object in memory.
7. Does the COPY FUNCTION in a data class create a DEEP COPY?
No, it creates a shallow copy, so nested mutable objects are shared.
8. Can a DATA CLASS implement an INTERFACE?
Yes, it can implement interfaces and override their methods.
INTERVIEW
Shopify Internship – Mobile Foundations Team (React Native)
● Worked on performance issue related to background data preloading in the Shopify
mobile app.
● Initial implementation:
○ Used JavaScript timers (setTimeout, setInterval) to fetch merchant data while the
app was idle.
○ On Android, timers were unreliable when:
■ App was backgrounded.
■ Device entered Doze mode.
○ Problems encountered:
■ Callbacks not firing or firing too late → caused stale data.
■ Added load to the JS thread, causing UI lag/jank.
■ Frequent polling kept the app awake → battery drain and wake lock
issues.
● Solution: Built a native Kotlin module using WorkManager.
○ Allowed scheduling background tasks with constraints (e.g., “only on Wi-Fi”,
“only while charging”).
○ Exposed Kotlin functionality to JavaScript via @ReactMethod.
○ Returned async results to JS using Promises.
○ Pushed updates to JS using event emitters.
● Results:
○ Offloaded work from JS thread → reduced UI lag.
○ Improved task reliability in backgrounded states.
○ Lowered battery consumption.
○ Gained hands-on experience bridging native code with React Native.
Kotlin Side – Technical Details
● Native Module Setup:
○ Created a Kotlin class extending ReactContextBaseJavaModule (standard way
to expose Android features to React Native).
○ Method: scheduleBackgroundTask – received parameters from JS:
■ Task ID.
■ Interval.
■ Constraints (e.g., network type).
● Scheduling with WorkManager:
○ Used PeriodicWorkRequestBuilder to schedule jobs.
○ Jobs could run even if:
■ App was closed.
■ Device rebooted.
○ Tasks were lightweight (e.g., network fetches, data refreshes).
○ Followed Android power optimization rules.
● JS ↔ Kotlin Communication:
○ Promises for one-off calls.
○ Event emitters for ongoing updates (job complete/failure).
● Thread Safety & Lifecycle Management:
○ Used synchronized blocks to handle concurrency.
○ Implemented lifecycle observers to manage app state changes.
● Outcome:
○ Abstracted native complexity → made background work scheduling simple for
other devs.
During my internship at Shopify, I worked with the Mobile Foundations team using React Native,
and I was tasked with solving a performance issue related to background data preloading. The
app initially used JavaScript timers (setTimeout, setInterval) to fetch merchant data while idle,
but on Android, those timers became unreliable—especially when the app was backgrounded or
the device entered Doze mode. Sometimes the callbacks didn’t fire, or they fired too late,
leading to stale data. The timers also added pressure to the JS thread, causing occasional UI
lag and jank. On top of that, frequent polling kept the app awake, draining battery and triggering
wake lock issues. To fix this, I built a native module in Kotlin using WorkManager, which let us
schedule tasks with constraints like “only on Wi-Fi” or “only while charging.” I exposed the
module to JavaScript using @ReactMethod, handled async results with Promises, and pushed
updates via event emitters. This offloaded work from the JS thread, improved task reliability in
backgrounded states, and helped reduce battery consumption—all while giving me hands-on
experience bridging native code with React Native.
Can you explain a bit more what you did on the kotlin side for this??
Sure! So the native module I built was essentially a Kotlin class that extended
ReactContextBaseJavaModule, which is the standard way to expose Android functionality to
React Native. I created a method called scheduleBackgroundTask that took in parameters from
JavaScript — things like the task ID, interval, and constraints like network type. On the native
side, I used Android’s WorkManager with PeriodicWorkRequestBuilder to schedule background
jobs that would run even if the app was closed or the device rebooted. The tasks themselves
were lightweight — typically network fetches or data refreshes — and they were designed to
respect Android’s system-level power optimizations. I also implemented communication back to
the JS layer using Promises for one-off calls and event emitters for ongoing task updates, like
when a job completed or failed. One tricky part was making sure everything was thread-safe
and lifecycle-aware, since React Native apps can be paused or backgrounded unpredictably. I
used synchronized blocks and lifecycle observers to handle that. Overall, the module abstracted
away all the native complexity from the JavaScript side, making it easy for other devs on the
team to schedule background work without worrying about the platform details.
JAVA
Here’s a one-bullet-per-concept quick rundown of Java OOP concepts:
● Class – Blueprint defining properties (fields) and behaviors (methods) of objects.
● Object – An instance of a class with its own state and behavior.
● Encapsulation – Bundling data and methods together, restricting access with access
modifiers (private, public, etc.).
● Inheritance – Creating a new class from an existing one to reuse and extend
functionality (extends).
● Polymorphism – Ability of different classes to respond to the same method call in
different ways (overriding, overloading).
● Abstraction – Hiding implementation details and exposing only essential features (via
abstract classes or interfaces).
● Interface – Contract defining methods a class must implement, supporting multiple
inheritance of type.
● Method Overloading – Same method name with different parameter lists in the same
class.
● Method Overriding – Subclass providing its own implementation for a method defined
in the parent class.
● Constructor – Special method used to initialize new objects.
● this keyword – Refers to the current object instance.
● super keyword – Refers to the immediate parent class (used for methods, fields, and
constructors).
If you want, I can also make a visual one-pager Java OOP cheat sheet for fast interview prep.