tezvyn:

📱Mobile Dev

Mobile app development across platforms

1323 bites

More in Mobile Dev — page 31

What is a suspend function in Kotlin and its compiler rules?
Android & Kotlin2 min read

What is a suspend function in Kotlin and its compiler rules?

This tests your understanding of suspendable computations and compiler transformation. A strong answer notes non-blocking suspension, the call-from-suspend-context rule, and compiler support for pausing and resuming. A red flag is claiming they block threads.

Explain the difference between launch and async in Kotlin Coroutines
Android & Kotlin2 min read

Explain the difference between launch and async in Kotlin Coroutines

This tests scope behavior and side effects versus results. A strong answer says launch returns a Job for side effects, async returns a Deferred for results, and both are scope children. A red flag is using async for all tasks or ignoring exception handling.

What does inline solve for higher-order functions, and what is reified?
Android & Kotlin2 min read

What does inline solve for higher-order functions, and what is reified?

It tests lambda overhead and type erasure. Answer: inline flattens lambdas into call sites to remove allocation and virtual calls; reified needs inline so the compiler knows the concrete type at the call site, enabling is T checks.

Compare Kotlin apply and let scope functions
Android & Kotlin2 min read

Compare Kotlin apply and let scope functions

WHAT IT TESTS: Your grasp of Kotlin scope mechanics. ANSWER OUTLINE: Apply uses this and returns receiver for configuration; let uses it and returns lambda result for null-safe transforms. RED FLAG: Calling them interchangeable or ignoring return values.

When would you use a sealed class instead of an enum?
Android & Kotlin2 min read

When would you use a sealed class instead of an enum?

This tests closed hierarchies versus singleton constants. A strong answer contrasts enums with sealed class instances, shows a NetworkResult example with data-bearing branches, and highlights exhaustiveness.

Explain higher-order functions and implement filterAndTransform
Android & Kotlin2 min read

Explain higher-order functions and implement filterAndTransform

Tests whether you can define higher-order functions and use lambdas idiomatically in Kotlin. A strong answer defines HOFs as functions that take or return functions, then implements filterAndTransform with filter and map.

Explain lateinit var versus val by lazy in Android
Android & Kotlin2 min read

Explain lateinit var versus val by lazy in Android

Tests deferred initialization and lifecycle coupling. Great answers contrast lateinit var's imperative assignment with lazy's first-access delegation, mapping lateinit to injected Activity fields and lazy to expensive computed objects.

What are the primary advantages of using a data class?
Android & Kotlin2 min read

What are the primary advantages of using a data class?

Tests Kotlin boilerplate reduction and value semantics. Name three generated functions like equals, hashCode, and copy; explain structural equality; and show copy updating immutable UI state.

What is an extension function? Write a hasWhitespace extension for String.
Android & Kotlin2 min read

What is an extension function? Write a hasWhitespace extension for String.

WHAT IT TESTS: Kotlin extensions are static dispatch, not true members. ANSWER OUTLINE: Explain receiverType.functionName adds behavior without inheritance; write hasWhitespace with any { it.isWhitespace() }. RED FLAG: Extensions modify classes or override.

Explain val vs var in Kotlin and null safety risks
Android & Kotlin2 min read

Explain val vs var in Kotlin and null safety risks

WHAT IT TESTS: Kotlin mutability and compile-time null safety. ANSWER OUTLINE: val is read-only, var is mutable; nullables use ? like String?; risk is NullPointerException if checks are missed. RED FLAG: Calling val deep immutability or defaulting to !!.

Navigate between feature modules without direct dependencies?
Android & Kotlin2 min read

Navigate between feature modules without direct dependencies?

Tests dependency inversion in modular apps. Answer by defining navigation interfaces in a shared module, implementing them in the :app module, and using DI to connect them. A red flag is suggesting direct module dependencies or using reflection for navigation.

Combine two network sources using Coroutines and Flow
Android & Kotlin2 min read

Combine two network sources using Coroutines and Flow

Tests your grasp of async data combination and state management. A good answer uses Flow.combine in a ViewModel, fed by a Repository, emitting a sealed class for UI state (Loading, Success, Error). A red flag is trying to combine state in the UI layer itself.

Explain the purpose of a UseCase or Interactor layer
Android & Kotlin2 min read

Explain the purpose of a UseCase or Interactor layer

Tests your grasp of separation of concerns. A great answer defines a UseCase as a single, reusable business operation that sits between the ViewModel and Repository. It keeps other layers clean and focused.

How do you share a ViewModel between Fragments?
Android & Kotlin2 min read

How do you share a ViewModel between Fragments?

Tests your understanding of ViewModel lifecycle scoping beyond a single screen. To share, scope the ViewModel to the parent Activity or a navigation graph using `activityViewModels()` or `navGraphViewModels()`.

How to use a nested navigation graph for a login flow?
Android & Kotlin2 min read

How to use a nested navigation graph for a login flow?

Tests your ability to structure complex UI flows using Navigation Component. A great answer defines a separate login graph XML, includes it in the main graph, and navigates to the graph's ID. This encapsulates the flow, making it reusable.

Why is LiveData<Boolean> bad for one-time ViewModel events?
Android & Kotlin2 min read

Why is LiveData<Boolean> bad for one-time ViewModel events?

Tests if you know LiveData holds state, not events. A good answer explains that LiveData re-emits on configuration changes, causing repeated events. The solution is to model events as part of the UI state and consume them.

How do you pass data between Fragments with Jetpack Navigation?
Android & Kotlin2 min read

How do you pass data between Fragments with Jetpack Navigation?

Tests knowledge of modern, type-safe argument passing. A good answer defines the argument in the nav graph XML, uses the Safe Args plugin to generate Directions/Args classes, navigates with the action, and retrieves the data in the destination via `by…

Explain ViewModel, Repository, and Data Source in MVVM
Android & Kotlin2 min read

Explain ViewModel, Repository, and Data Source in MVVM

This tests your understanding of separation of concerns. A great answer defines ViewModel (UI state), Repository (data abstraction), and Data Sources (implementation), then explains the unidirectional data flow.

What is a Jetpack ViewModel and the problem it solves?
Android & Kotlin2 min read

What is a Jetpack ViewModel and the problem it solves?

This tests your understanding of lifecycle-aware state preservation. A good answer explains that ViewModels survive configuration changes (like rotation) to hold UI data, separating it from the transient UI controller.

How do you diagnose and fix excessive recomposition in Jetpack Compose?
Android & Kotlin2 min read

How do you diagnose and fix excessive recomposition in Jetpack Compose?

This tests your grasp of Compose's stability system. First, use Layout Inspector to find high-recomposition areas. Then, enable and analyze the Compose compiler report to diagnose unstable parameters (like List) or lambdas.