A repository containing interview questions on DS, Java & Android based on my experiences.
Note: I am not writing up the answers here for now as If I provide you the answers, what will you do? :-)
Also, you will restrict yourself to those answers only. Try and learn more deeply abut the concepts. For any particular questions, You can ask anytime.
Continuation Question to
32, What is the time complexity of your solution and how can you improve it?
What is the time complexity of mergeSort, quickSort and Binary search?
What is the time complexity for removing an element from LinkedList?
Interfaces vs Abstract Classes.Why Interfaces if abstract classes are already there.
JAVA 8 new features
Hashmap implementation,ArrayList implementation
How to make a class immutable.
String pools,intern keyword,new() keyword
Linked list vs Array,Array vs ArrayList,Set vs List vs Map,Iterator vs Enumeration.
How to compare two objects in Set?(hint : equals() and hashcode() overriding)
How ClickListener implemented in Java?
Programs based on Inheritance and multithreading. (Most Important)
1.) Add(String string) 2.) Add (Object object), you called Add(null) what will be the output here?
Why main Static?
Static vs Singleton? Which to prefer when?
Can a static method be overloaded/overridden?Can a constructor be made static? Can we override/overload constructor? Which type of error you get-Compile/Runtime.
Can we have final/static/default methods in interface/abstract classes?
Check for every keyword? Which type of error-Compile time or runtime(I remember it after I tried a sample in Android studio).
Stack vs Heap allocation in Java.
Why is String immutable?
Why reflection in Java?Introspection vs Reflection?
Anonymous vs Inner Classes.Static Inner Classes. Can we have Static inner classes on Top?
What is the naming structure for an inner class in java?
Default value for Access specifiers,primitie types.
Protected vs Default. Do static retain value if an application is removed from recent.
How is the Exception class implemented in java?Try/Catch with finally block.
Any situation when finally won’t get executed?
Is Java pass by value/reference?
What will be the result if StringBuffer value compared with String — strbuf.equals(str) /str.equals(strbuf)
Synchronization in Java.
Can one interface extend/implement other/Can one abstract class extend other? Can interface extend abstract classes?
Runtime vs compile time polymorphism with real-world scenarios. How do you define encapsulation?
this vs super() keyword
Implement own Garbage collection in java.
Why runnable interface if we have already had Thread class in Java?
Why thread pool in Java?
Order of call of constructors during Inheritance.
Why should we use Kotlin for Android Development?
Kotlin operators - apply, run, let, ?
How Kotlin is null-safe?
What is the difference between var and val?
How const is different from val?
What is the difference between ?. and !!
How to define static functions in Kotlin?
What are Data Classes in Kotlin?
What do you mean by Sealed classes in Kotlin?
Collections in Kotlin.
Difference between lateinit and lazy.
What is Kotlin synthetic binding?
Difference between Kotlin Synthetics, View binding and Butterknife?
What are extension functions in Kotlin?
What are lambda expressions?
What are Higher-Order functions in Kotlin?
Difference between let, run, with, also, apply in Kotlin.
What is the best way for performing tasks on a background thread in kotlin?
What are Coroutines in Kotlin?
What are the different Coroutines Scope?
Why use suspend function in Kotlin Coroutines?
Explain Coroutine LifecycleScope.
What is Kotlin Flow?
Kotlin Flow vs RxJava.
Room vs Realm? Why not Realm?
(Also they ask for code not just theory things. Keep this in mind.)
Activity/Fragment/Broadcast/Application/Service Lifecycle (Explain with one line description)
Which lifecycle method gets called when A goes to B/come back to A? Activity Launch Modes with examples
Let’s say 4 activities are there A->B->C->D. How to launch A from D finishing in between activities?
4 Activities are there A->B->C->D.How to finish application from D if none of the activities opened earlier finished till now?
How CLEAR_TOP flag intent works in android?
Service vs IntentService?When to prefer which type of service?
Explain ways for Activity to activity communication/Activity to fragment communication/Fragment to fragment communication.
How to make a service persist even after Application killed?
How to achieve Interprocess communication in android?
How Async task internally works? Async task implementation?
Cons of using Async task? How to overcome this limitation?
Why Job Scheduler?
Notification related changes in Oreo?
How to handle Background service and execution limits with new Oreo Updates?
Have you seen Google I/O 2018? What were the updates for Android there?
Why do we use Headless fragments?
Memory Leakage, Causes, and preventions in Android? I have written a blog out here.You can refer this too
Ways to optimize an Android Application.
Proguard-Obfuscation/ Minification, Build Variants, Flavours.
How to achieve MultiThreading in Android?
Suppose you have 10 images to fetch from Server. What is the best way to fetch images? (Hint: Read about ThreadPool and Executor)
Builder vs Factory Pattern with an example
Why MVP not MVC? They will ask you to make a wireframe kind of thing on paper to demonstrate MVP pattern in android.
Why RXJAVA so popular nowadays?
Problems in RXJAVA? They can provide you with some scenarios to get to know if you can find out the problems with it.
Map vs Flat map? (Most commonly asked in RXJAVA)
Should we provide a context in presenter/Model? Answering yes/no is not enough. You have to provide a solution for it.
Why Schedulers and How Rxjava internally works with them? SusbcribeOn vs ObserveOn, Schedulers on which both of these work? .subscribe(new Subscriber…) vs .subscribe(new Observer…)
IOScheduler/new Thread Scheduler in RXJava
How dagger internally worksDagger vs Dagger2? Explain the purpose of every annotation taken in Dagger2.
How do you decide scope in Dagger? Why Qualifier annotation?
Why do we use Handlers? Do you know the Loopers? What’s the role of Message queue? With this, they will go for Main Thread working. They will also ask you about the exceptions we get as Looper.prepare() exceptions
Cause of Memory leak during the Async Task?
Explain Singleton pattern. Problems with it and Handling. (hint: Double checked locking/synchronization)
Why do you prefer Retrofit over Volley? Why Picasso? Now they will ask all the third party libraries you have used. Be honest with your answer. They may go deep in any of those.
Why ConstraintLayout?Barriers vs Guidelines, Why Group/Chains?
Why do we prefer Framelayout for Fragments?
Why ANR?How to prevent it?
Do async.execute make threads in parallel or serial?
How to make a custom view in android? Explain lifecycle methods. Difference between onLayout/onMeasure.
Have you ever faced any issue with SingleInstance launch mode or example if you have used it? Providing real-life examples are preferred more.
When 1 fragment added over another-Explain lifecycle methods. Another question would be if you replace instead of adding it. The 3rd question will be if you have back stack there.
Why fragment newInstance() is there (Best practice for instantiating a new Android Fragment)
Suppose you have to update location every minute even if you don’t get permission. But the tricky thing here is how will you notify the server-Through the same service you were sending updates using FusedLocationProvider/Will you use some other service or broadcast. Just design the whole thing.
Observable.just/Observable.from/Observable.create in RXJAVA?
Why Instant Apps? How do you achieve this?
How to load Large Bitmaps? Handle Memory leaks and Sample sizing
How parcelable internally works? Design it.
What happens if your serializable class contains a member which is not serializable? How to handle it?
Why do we use WeakReferences?
How to retain data on orientation change? Explain lifecycle during orientation changes.
How to make endless circular recyclerView?
Suppose you have given an array of array of custom Objects. Which data structure will you use to show these on UI?
How do you handle opening activity using notifications?
How to achieve Push notifications in android? Explain behavior during App in front/Background-How to handle both scenarios.
How to download files in parallel?
Why Realm?Realm Methods, Realm vs Sqlite.
How to handle different screen sizes/density/languages/orientation in android?
What the Fragment’s method setRetainInstance(boolean) does?
Keep yourself up to date with the latest library versions if using.
Why is there a need for JobIntentService?(hint:: Oreo update)
Basics for Testing in Android-They will ask some questions about Espresso,mockito,roboelectric(not in that deep).Stub vs mock. Also if you are following MVP pattern. Be prepared for the questions now.
How the OS handles process flow. When is the app killed or removed from recent memory? How OS decides this.
Which method gets called when home button pressed, back pressed etc.(Most commonly asked)
Manifest related attributes -allowBackup,intent-filters,process,taskAffinity,permission vs uses-permission etc.
Draw a simple basic design you follow to make an android application(folder structure, methods, variables)
Why services preferred over Broadcast receiver for background applications
Broadcast-related changes in Oreo and Handling them.
Accessibility services in android. How do you handle system apps(I mentioned this work too, so asked)
Thread.start() vs run method,submit vs Execute ,callable vs runnable
View Holder pattern.ListView vs RecyclerView.
Remote Views and How to use them?
Inner Classes vs Static Classes?
Volatile vs Transient
Internal Implementation of Picasso, Glide
Internal implementation of Recyclerview
Design Patterns and Practical Usage
Custom View and Lifecycle
Singleton vs Static and why we use them?
Deep vs Dynamic Linking
Livedata postValue vs set
Livedata vs ObservableField
HashCode and Equals Implementation
Dagger - Component vs SubComponenets
TDD and frameworks - if using , tell the challenges faced
GSON vs Jackson vs Moshi
Android Bundle - and Dynamic Feature usage
Proguard vs R8
What is Scoped Storage and how to implement?
Observable vs Completable vs Single
Rx vs Coroutines. Which one you prefer and when?
Difference between MVP and MVVM?
Explain SOLID principles?
Difference between const and val
When is onPause() called without onStop() being called?
Dagger vs Koin?
Any 5 RxJava operatrs. How subscribeOn and observeOn works?
Workmanager, type of requests, methods, minimum interval before a job repeat itself.
Workmanager vs JobScheduler.
Why ConstraintLayout? Tell some properties which I find worth.
How SharedPreferences work internally?
You will be given assignments as your first/last round. They just want to know how you follow the standards. Some ask for UI thing, other ask for architectural patterns. Just check your methods and play well with the logic.That’s all.
Design Whatsapp/Chat application/Facebook messenger.
Implement search functionality with debounce operator (If user keeps on typing, then cancel the last network call and hit for the present one, How will you achieve that?)
Design a Location Tracking application
If you learn about the concepts for the above questions, I am sure you will get your basics strong and with the strong basics, you can easily crack any interview.
I have written an article on the same.
If you have more questions, I will be happy to learn, add & share. Please raise a PR and contribute. :-)