Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

📚 Questions for Android Engineer Interview 📚

NotificationsYou must be signed in to change notification settings

AndroidDeveloperLearning/android-interview

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 

Repository files navigation

AndroidKotlin

Let's Learn for Free!Click Here

Book 1:1 Session here ->Click Here

Complete Android Engineer Roadmap

Interview Contents

Kotlin

  • What is the difference betweenconst val andval?
    • Both are used to define read-only properties, but
    • const val properties should be initialized at compile-time whereasval properties can be initialized at runtime
    • If we decompile,const val variable will replace with its value butval not, because it can be initialized at runtime
    • const val BASE_URL = "https://github.com"val githubHandle = "anandwana001"val repoName: String
  • What is so interesting aboutdata class?
    • Uses to hold data
    • Pre-functions liketoString,equals,copy, andcomponentN
    • Data classes cannot be abstract, open, sealed, or inner.
    • Data classes cannot extend other classes
    • Supports destructuring declaration
  • Is singleton thread-safe? vs Object?
  • What are the different types of scope functions?
    • Let =T.let { R }
      • lambda result (R) is the return type
      • can be performed on anyT type object
      • lambda reference isit
      • suitable for null check
    • Run =T.run { R }
      • same aslet, but mostly used in initializing an object
      • lambda reference isthis
      • suitable for null check
    • With =with(T) { R }
      • if T is nullable object userun else usewith(T)
      • lambda reference isthis
      • not suitable for null check
    • Also =T.also { T }
      • when need to perform multiple operations in chain usealso
      • lambda reference isit
    • Apply =T.apply { T }
      • when need to perform the operation on theT object and return the same useapply
      • lambda reference isthis
      • suitable for null check
  • What are the different Coroutine Scopes?
  • How to manage series and parallel execution?
  • Difference between Flow/SharedFlow/StateFlow and elaborate it.
  • What happens if we call.cancel() from a coroutine scope?
  • What is an Init block in Kotlin?
  • How to choose between apply and with?
  • What is inline function in Kotlin?
  • Difference between Coroutine and Java Thread
  • Why Coroutines are light weight?
  • How does Coroutine switch context?
  • When to use Kotlin sealed classes?
  • Suspending vs Blocking in Kotlin Coroutines
  • What are Dispatchers and Name all of them
  • On which thread Dispatchers .Default execute the task or use which thread?
  • Dispatchers .Default vs Dispatcher .IO
  • What is SupervisorScope?
  • Exception Handling in Coroutine
  • Map vs FlatMap in kotlin
  • Singleton Pattern in Kotlin with object keyword
  • Collections API in Kotlin
  • What is Unidirectional Flow
  • StateFlow vs SharedFlow
  • Builder Pattern in Kotlin
  • Higher Order Functions in Kotlin
  • Covariance in Kotlin
  • Delay vs Thread.sleep?Answer

Android

  • How does Garbage collection works?
  • What is a dangling pointer?
  • Elaborate Memory Leak?
  • Explain fragment Lifecycle when it comes to ViewPager and sliding between different fragments.
  • Difference between FragmentStateAdapter and FragmentStatePagerAdapter.
  • Difference between Serializable and Parcelable? What are the disadvantages of Serializable?
  • How you could implement observable SharedPrefs or observable Databases i.e. Observe a certain key/table/query?
  • How does layout inflation work from xml tags to view references in memory?
  • What is a Thread, Handler, Looper, and Message Queue?
  • What are the different methods of concurrency on Android? Can you explain the difference between ExecutorService vs CachedThreadPool vs FixedThreadPool vs AsyncTasks vs HandlerThreads?
  • How doesViewModel instance provide to Activity and Fragment? How doesViewModelProviderStore decide when to retain the instance?
  • How do you inspect and solve the Jank issue?here
  • How does the OutOfMemory happen?
  • How do you find memory leaks in Android applications?
  • What is Doze? What about App Standby?
  • What doessetContentView do?
  • Process of creating a custom view
  • Deeplink understanding and architecture
  • Notifications
  • Difference between Fragment Lifecycle Observer and View Lifecycle Observer.
  • When should you use a Fragment rather than an Activity?
  • Explain the Android push notification system.
  • How LiveData is different from ObservableField?
  • What is the difference between setValue and postValue in LiveData?
  • What is process death?
  • What is ViewModelScope and How does it work internally?

Lifecycle

  • How to keep a video maintain a playing state when we rotate the screen?
  • How many callbacks are in Fragments?
  • What could be the reasons whyonPause didn't get triggered?
  • What kind of events triggeronPause() to run?
  • In what scenario does the "onDestory" get called directly after "onCreate"?
  • Which callback gets called on Activity when an AlertDialog is shown?
  • What's the lifecycle in PIP (Picture-in-Picture)?
  • What happens if you rotate the device?
  • Inside a viewpager (Fragment state pager adapter) what will be the lifecycle of the fragments when you swap from one tab to another?
  • Why onActivityCreated is now depreciated in Fragment?
  • Which callback should I use if I want to know when my activity came to the foreground?
  • When is onActivityResult called?
  • What does setRetainInstance do and how you can avoid it?
  • What callbacks trigger when a Dialog opens up? In both cases, the dialog is attached from the same activity/fragment and another activity/fragment.
  • What dolaunchWhenCreated,launchWhenStarted, andlaunchWhenResumed functions do?
  • Fragment Callbacks when moving from one fragment to another and coming back to prev one?
  • Does onCreateView get called after coming to a fragment from top fragment?
  • When does ViewModel not survive

Important Lifecycle Points to Remember

Opening a fragment from Activity

Code

supportFragmentManager.beginTransaction()    .replace(R.id.fragment_container, FragmentA())    .commit()

Callbacks

MainActivityonCreate
FragmentAonAttach
FragmentAonCreate
FragmentAonCreateView
FragmentAonViewCreated
FragmentACREATED == Lifecycle.State
FragmentAonViewStateRestored
FragmentAonStart
FragmentASTARTED == Lifecycle.State
MainActivityonStart
MainActivityonResume
FragmentAonResume
FragmentARESUMED == Lifecycle.State
MainActivityonAttachedToWindow

Adding a Fragment from a Fragment

Code

parentFragmentManager.beginTransaction()    .add(R.id.fragment_container, FragmentB())    .commit()
parentFragmentManager.beginTransaction()    .add(R.id.fragment_container, FragmentB())    .addToBackStack(null)    .commit()

Callbacks

FragmentBonAttach
FragmentBonCreate
FragmentBonCreateView
FragmentBonViewCreated
FragmentBCREATED == Lifecycle.State
FragmentBonViewStateRestored
FragmentBonStart
FragmentBSTARTED == Lifecycle.State
FragmentBonResume
FragmentBRESUMED == Lifecycle.State

Replacing a Fragment from a Fragment

Code

parentFragmentManager.beginTransaction()    .replace(R.id.fragment_container, FragmentB())    .addToBackStack(null)    .commit()

Callbacks

FragmentAonPause
FragmentAonStop
FragmentBonAttach
FragmentBonCreate
FragmentBonCreateView
FragmentBonViewCreated
FragmentBCREATED == Lifecycle.State
FragmentBonViewStateRestored
FragmentBonStart
FragmentBSTARTED == Lifecycle.State
FragmentAonDestroyView
FragmentBonResume
FragmentBRESUMED == Lifecycle.State

Code

parentFragmentManager.beginTransaction()    .replace(R.id.fragment_container, FragmentB())    .commit()

Callbacks

FragmentAonPause
FragmentAonStop
FragmentBonAttach
FragmentBonCreate
FragmentBonCreateView
FragmentBonViewCreated
FragmentBCREATED == Lifecycle.State
FragmentBonViewStateRestored
FragmentBonStart
FragmentBSTARTED == Lifecycle.State
FragmentAonDestroyView
FragmentAonDestroy
FragmentAonDetach
FragmentBonResume
FragmentBRESUMED == Lifecycle.State

Coming Back to Previous Fragment after Adding

Note: IfaddToBackStack is not used, and back stack is empty, nothing will happen when callingpopBackStack() function

Code

// FragmentAparentFragmentManager.beginTransaction()    .add(R.id.fragment_container, FragmentB())    .addToBackStack(null)    .commit()// FragmentBparentFragmentManager.popBackStack()

Callbacks

FragmentBonPause
FragmentBonStop
FragmentBonDestroyView
FragmentBonDestroy
FragmentBonDetach

FragmentA is visible. No FragmentA callbacks as FragmentA is always there, neither the view nor the lifecycle get affected.

Coming Back to Previous Fragment after Replacing

Note: IfaddToBackStack is not used, and back stack is empty, nothing will happen when callingpopBackStack() function

Code

// FragmentAparentFragmentManager.beginTransaction()    .replace(R.id.fragment_container, FragmentB())    .addToBackStack(null)    .commit()// FragmentBparentFragmentManager.popBackStack()

Callbacks

FragmentBonPause
FragmentBonStop
FragmentAonCreateView
FragmentAonViewCreated
FragmentACREATED == Lifecycle.State
FragmentAonViewStateRestored
FragmentAonStart
FragmentASTARTED == Lifecycle.State
FragmentBonDestroyView
FragmentBonDestroy
FragmentBonDetach
FragmentAonResume
FragmentARESUMED == Lifecycle.State

FragmentA view is created again. When replacing, the FragmentA view gets destroyed,onDestroyView gets called so when coming back it callsonCreateView to initialise the view again.Though,onCreate will not get called again.

Lifecycle State

There are 5 States:

  • DESTROYED
  • INITIALIZED
  • CREATED
  • STARTED
  • RESUMED

Points to Remember

States are based on Context/Scope you are using in.Example:

viewLifecycleOwner.lifecycleScope.launch {    repeatOnLifecycle(Lifecycle.State.CREATED) {        //...    }}// viewLifecycleOwner => Lifecycle of the View// should be used between onCreateView() and onDestroyView()
this.lifecycleScope.launch {    repeatOnLifecycle(Lifecycle.State.CREATED) {        //...    }}// this => Lifecycle of Fragment or Activity
CREATED- listen inonDestroyView (if not View lifecycle) and inonStop,onSavedInstance too
STARTED- listen inonStart,onPause
RESUMED- listen inonResume
DESTROYED- listen inonDestroyView (if View lifecycle) and inonDestroy
CREATED- listen inonViewStateRestored (if View lifecycle)
CREATED- listen inonCreate,onCreateView,onViewCreated,onViewStateRestored (if not View lifecycle)

Examples

  • if state CREATED and app moves to background, it will listen. Hence, Avoid UI work here
  • use state CREATED if need to complete action even after Fragment View destroy

Networking

  • What is the role of OkHttp and Retrofit?
  • What design pattern does Retrofit use?
  • How would optimize the handling of access token expiration? How would you handle a retry network call when the API fails? (Custom Interceptor response)

Webview

  • What are the problems around security when dealing withWebView?
  • How to interact or make connections with JavaScript?

Dependency Injection

  • Provides vs binds
  • Subcomponent vs. component dependency, what is the difference under the hood
  • What is a subcomponent and what is its use? How do you use qualifiers or how would you provide different instances of a class with the same data type? Constructor Injection V/s Method Injection? What is the scope? Singleton Annotation?
  • What is Circular dependency in dagger? and how to resolve it
  • What's interesting about Hilt?
  • Did you use Koin? What are your thoughts on it?

Jetpack Compose

  • How to launch a coroutine from a composable function? -LaunchedEffect
  • How to launch a coroutine from a non-composable function, but tied to composition? -rememberCoroutineScope()
  • What is recomposition?Recomposition
  • What isremember in compose?
    • A composable function to remember the value produced by a calculation only at the time of composition. It will not calculate again in recomposition.
    • Recomposition will always return the value produced by composition.
    • Whole Compose is based on the concept ofPositional Memoization
    • At the time of recomposition,remember internally calls a function calledrememberedValue() whose work is to look into theslotTable and compare if the previous value and the new value have any difference, if not return, else update the value
  • Why and when to useremember {}?
  • Difference betweenLazyColumn andRecyclerView?
  • What is AndroidView in compose?
  • What is the lifecycle of composeables?Lifecycle
  • How to avoid recomposition of any composable, if the state is not changed?Smart Recomposition
  • What are stable types that can skip recomposition?
  • What is State?
  • What is MutableState and how does recomposition happen?
  • How to retain State across recomposition and configuration changes?
  • Difference between Stateless and Stateful composeables?
  • What are your thoughts on flat hierarchy, constraint Layout in compose vs. the older view hierarchy in xml
  • Difference b/w remember and LaunchedEffect
  • Does re-composition ofComposeItem1 bring any effect onComposeItem2? If yes, then how?
    • ComposeParent() { ComposeItem1 {} ComposeItem2() {...} }
    • What isCompositionLocal?
  • Custom views in compose
  • Canvas in Compose
  • What are the benefits of Jetpack Compose?
  • How does Jetpack Compose integrate with existing Android frameworks and libraries?
  • What are the best practices for performance optimization in Jetpack Compose?
  • How is navigation handled in Jetpack Compose?
  • What is Strong Skipping Mode?Answer

Thread

  • Different types of threads?
  • Difference between different types of thread?
  • Thread <-> Handler <-> looper
  • UI vs Background Thread
  • How do you know when some process if blocking a UI thread?

Architecture

  • What are SOLID principles?
  • What is MVVM?
  • Brief about Android Architecture.
  • MVP vs MVVM?
  • Is there any issue in the Presenter in the MVP?
  • Clean Architecture
  • MVVM vs MVI
  • What is Clean Architecture in MVVM
  • What are Provides and Binds in your Dagger library

Design Pattern

  • What is SOLID principle?
  • What are different design patterns you know about?
  • What is a creational pattern?
  • What is a structural pattern?
  • What is a behavioral pattern?
  • Create Singleton Pattern without Kotlin default implementation
  • Create Observer Pattern
  • Create Adapter Pattern
  • How to make a Singleton Pattern Thread Safe?
  • What is Dependency Inversion
  • Write a real-life example of Dependency Injection without using any library
  • Explain how Android Architecture components (ViewModel, LiveData, etc.) utilize design patterns behind the scenes

System Design

  • Design Image Loading Library
  • Design Image Downloading Library
  • Design LRU Cache
  • Design a real-time Twitter feed timeline. How will you structure the backend? Will you use WebSocket or REST for this use case? Justify.
  • Design Networking Library
  • Design Checkout Screen
  • Design Error handling Structure
  • REST <-> Web Sockets
  • Implement caching mechanism
  • Build an offline-first app
  • Design Analytics Library

Libraries

  • How does Glide internally work?
  • How does retrofit work internally?
  • ViewModel internal working
  • How will you choose between Dagger 2 and Dagger-Hilt?

Common Question

  • String vsStringBuilder
  • == vs.equals?
  • === vs==?
  • Java OOP concepts

Questions from Company

CompanyQuestions
Booking.com
  • Implement findViewById method
  • Given a list of words as input, output another list of strings, each containing words that are mutual anagrams
  • Identify whether four sides (given by four integers) can form a square, a rectangle or neither
  • Output a delta encoding for the sequence. In a delta encoding, the first element is reproduced as-is. Each subsequent element is represented as the numeric difference from the element before it
  • Three integer arrays are given with duplicate numbers. Find the common elements among three arrays
  • Twisted question related to ConcurrentModificationException in an ArrayList
  • How do you implement a hotel list and detail screen? Discuss what all APIs You will create and how the layout will be
  • Fragments & their lifecycle, Activity lifecycle, Views, Layouts
  • Background task in Android - Asynctask, service, intent services, etc
  • Given dates and number of check-in and check-out on those dates. Find the busiest day in the hotel. [Merge Array interval type question]
  • Given an array, determine if there are repeated elements. If an element is repeated more than 3 times, return those elements. This question is basically doing a hash and checking if the hash already exists. Someone used a Map and a Set.
  • Given a list of positive words, negative words, and a review, determine if the review is flagged as positive, negative, or neutral. Someone solved it using a Set. Someone just needed to do some count (+ or -) regarding where the word appeared (positive list or negative).
Spotify
  • Design components and overall architecture for a Search feature in an Android application. [Spotify - Android Engineer II - London, UK - Sep 2022]
  • Design a Disk based Cache for the client. [Spotify System Design Android/iOS Client]Platform independent, Key will be 32 bytes, Value can be anything but in Byte array, Cache should be persistent, Cache should max hold 100k+ Objects, Cache Max size should be configurable ( Max Size: 10 MB upto 1GB), Cache should be opaque, Cache should be Secure
  • Linked List Cycle
  • Palindrome Linked List
PhonePe
  • Minimum Meetroom scheduling
  • Anagram Strings based question
Paytm
  • To check if strings are rotations of each other or not. If they are in rotation print the no. of rotations.
  • Find the string is anagram or not
  • Design components and overall architecture for a Search feature in an Android application
  • Sort an array of 0s, 1s and 2s
  • Abstract vs Interface
  • Android Memory related
Meesho
  • SOLID principles
  • Dagger, why use dependency injection, what if we do not think it is important, like alternatives? How to create our own dependency injection library.
  • why use MVVM over MVP, think outside the box, we could have used observables using RxJava, etc. - open-ended questions around it
  • Multi-Module benefits and why use it
  • How to handle dependencies or abstraction in multi-module
  • val vs const
  • inline keyword
  • lateinit vs lazy

Android Roadmap 2024

TopicsSub-Topics
Programming Languages
  • Kotlin
  • Java
  • Android Architectureimage
    Runtime
  • Dalvik Virtual Machine
  • Android Runtime
  • Android Manifest
  • Package
  • Application Id
  • Permissions
  • Install-time Permissions
  • Special Permissions
  • Runtime Permissions
  • Permissions Groups
  • Android Build
  • APK
  • AAB
  • Thread
  • Processes
  • Threads
  • Inter Process Communication
  • Handlers
  • Loopers
  • Message Queue
  • UI Thread
  • Background Thread
  • Heap & Stack
  • Fundamental Components
  • Activity
  • Services
  • Broadcast Receiver
  • Content Provider
  • Intent
  • Implicit Intent
  • Explicit Intent
  • Intent Filters
  • Intent Flags
  • Activity
  • Activity Lifecycle
  • Tasks and Back Stacks
  • Bundles
  • Parcelables
  • Recent Screens
  • App Shortcuts
  • Context
  • Services
  • Service Lifecycle
  • Foreground Service
  • Background Service
  • Bound Service
  • AIDL
  • Job Scheduler
  • WorkManager
  • IntentService
  • Broadcast Receiver
  • Pub-Sub
  • System Broadcast
  • Permissions
  • Security
  • Content Provider
  • Content Resolver
  • Cursor
  • MIME Types
  • Contracts
  • Data Storage
  • App Specific Storage
  • Shared Storage
  • Preferences
  • Database
  • Scoped Storage
  • LRU Cache
  • SQLite
  • ROOM
  • Data Store
  • Fragments
  • Fragment Lifecycle
  • Dialog Fragment
  • Fragment Transactions
  • Fragment Manager
  • View Lifecycle
  • BackStack
  • Fragment-Activity Communication
  • Fragment-Fragment Communication
  • Navigation Component
  • Host
  • Graph
  • Controller
  • Back Stacks
  • Destinations
  • Deeplink
  • Jetpack Components
  • ViewModel
  • LiveData
  • Paging
  • Lifecycle
  • WorkManager
  • Data Binding
  • UI
  • XML
  • Jetpack Compose
  • Jetpack Compose
  • Composition
  • ReComposition
  • State Hoisting
  • Remember
  • RememberSaveable
  • Side Effects
  • LaunchedEffect
  • DisposableEffect
  • DerivedStateOf
  • SnapshotFlow
  • CompositionLocal
  • Theming
  • Modifier
  • Layouts
  • Box/Column/Row
  • Image/painter
  • Coil
  • LazyColumn/LayRow
  • Text/Button/ other ui components
  • Testing
  • UI Testing
  • Unit Testing
  • Espresso
  • Robolectric
  • Mockk
  • Debugging
  • Logcat
  • Timber
  • Break Points
  • Chucker
  • Charles
  • LeakCanary
  • Libraries
  • Retrofit
  • OkHttp
  • Glide
  • Material3
  • Hilt
  • Dagger
  • Retrofit
  • Benchmark
  • Micro Benchmark
  • Macro Benchmark
  • Static Analysis
  • Ktlint
  • Detekt
  • Android Lint
  • GitHub Actions
  • Pipeline
  • Build Generation
  • Workflow
  • Gradle
  • Commands
  • Groovy
  • Common Errors
  • ANR
  • App Crash
  • Fatal Error
  • OOM
  • ArrayOutOfBound
  • Proguard
  • Obfuscation
  • Keep
  • Code Architecture
  • MVP
  • MVVM
  • MVI
  • Modularization
  • Design Patterns
  • Network Layer
  • Data Layer
  • UI Layer
  • Domain/Repository/...
  • Firebase
  • Crashlytics
  • Remote Config
  • A/B Testing
  • App Release
  • App Release Process
  • App Distribution
  • Google Play Console
  • App Review/Ratings
  • App Size
  • App Policies

  • Kotlin Sheet 2024

    Jetpack Compose Sheet 2024

    Contributing Guidelines

    What interesting questions do you face while giving an interview for an Android Engineer role (any level)? Let's open a PR.

    If this Repository helps you, Show your ❤️ by buying me a ☕ below.

    Buy Me A Coffee

    If this repository helps you in any way, show your love ❤️ by putting a ⭐ on this project ✌️

    About

    📚 Questions for Android Engineer Interview 📚

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    [8]ページ先頭

    ©2009-2025 Movatter.jp