Convert Figma logo to code with AI

amitshekhariitbhu logoandroid-interview-questions

Your Cheat Sheet For Android Interview - Android Interview Questions and Answers

11,210
2,224
11,210
10

Top Related Projects

Extensive Open-Source Guides for Android Developers

A curated list of awesome Android packages and resources.

A curated list of awesome Android UI/UX libraries

:ballot_box_with_check: [Cheatsheet] Tips and tricks for Android Development

Quick Overview

The "android-interview-questions" repository is a comprehensive collection of Android interview questions and answers. It serves as a valuable resource for Android developers preparing for job interviews, covering a wide range of topics from basic to advanced concepts in Android development.

Pros

  • Extensive coverage of Android-related topics
  • Well-organized and categorized questions
  • Regularly updated with new content
  • Community-driven with contributions from various developers

Cons

  • Some answers may lack depth or detailed explanations
  • May not cover all company-specific or niche Android topics
  • Potential for outdated information as Android evolves rapidly
  • Relies on self-study and may lack interactive learning elements

Code Examples

This repository is not a code library, so code examples are not applicable.

Getting Started

As this is not a code library, there are no specific getting started instructions. However, to use this resource effectively:

  1. Visit the repository: https://github.com/amitshekhariitbhu/android-interview-questions
  2. Browse through the README.md file to find questions organized by topic
  3. Use the table of contents to jump to specific sections of interest
  4. Study the questions and answers, and research further if needed
  5. Contribute to the project by submitting pull requests with new questions or improvements to existing answers

Competitor Comparisons

Extensive Open-Source Guides for Android Developers

Pros of android_guides

  • Comprehensive guide covering a wide range of Android development topics
  • Regularly updated with the latest Android practices and technologies
  • Includes practical examples and tutorials for hands-on learning

Cons of android_guides

  • Less focused on interview preparation specifically
  • May be overwhelming for beginners due to the breadth of content
  • Requires more time to navigate and find specific information

Code Comparison

android_guides:

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

android-interview-questions:

// What is the difference between Serializable and Parcelable?
// Serializable is a standard Java interface. Parcelable is an Android-specific interface.
// Parcelable is faster than Serializable interface
// Parcelable interface takes more time to implement compared to Serializable interface

The android_guides repository provides more practical code examples for implementation, while android-interview-questions focuses on concise explanations and code snippets related to interview topics.

A curated list of awesome Android packages and resources.

Pros of awesome-android

  • Broader scope, covering various aspects of Android development beyond interview questions
  • Regularly updated with new resources and tools
  • Includes links to libraries, frameworks, and other practical resources for developers

Cons of awesome-android

  • Less focused on interview preparation specifically
  • May be overwhelming for beginners due to the large amount of information
  • Lacks detailed explanations or examples for each topic

Code comparison

While both repositories primarily focus on curating resources rather than providing code examples, awesome-android does include some code snippets in its descriptions. For example:

awesome-android:

implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

android-interview-questions doesn't typically include code snippets, instead focusing on conceptual questions and answers.

Summary

awesome-android is a comprehensive resource for Android developers, covering a wide range of topics and tools. It's great for ongoing learning and discovering new libraries or frameworks. android-interview-questions, on the other hand, is more focused on interview preparation, providing specific questions and answers that are commonly asked in Android developer interviews. Choose based on your current needs: general Android development resources or interview preparation.

A curated list of awesome Android UI/UX libraries

Pros of awesome-android-ui

  • Focuses on UI components and libraries, providing a curated list of visually appealing and functional UI elements
  • Offers a wide range of categories, including Layout, Animation, Effect, and more
  • Includes visual examples and GIFs, making it easier to understand the UI components at a glance

Cons of awesome-android-ui

  • Lacks in-depth explanations or code examples for implementing the UI components
  • May not be as comprehensive for interview preparation or understanding core Android concepts
  • Some listed libraries might be outdated or no longer maintained

Code Comparison

While android-interview-questions provides code snippets for various Android concepts, awesome-android-ui primarily lists libraries without extensive code examples. However, here's a brief comparison of how they might present information:

android-interview-questions:

public class SingletonExample {
    private static SingletonExample instance;
    private SingletonExample() {}
    public static SingletonExample getInstance() {
        if (instance == null) {
            instance = new SingletonExample();
        }
        return instance;
    }
}

awesome-android-ui:

- [Lottie](https://github.com/airbnb/lottie-android) - Render After Effects animations natively on Android and iOS, Web, and React Native

The android-interview-questions repository provides more detailed code examples, while awesome-android-ui focuses on listing and briefly describing UI libraries and components.

:ballot_box_with_check: [Cheatsheet] Tips and tricks for Android Development

Pros of android-tips-tricks

  • More comprehensive coverage of Android development topics beyond just interview questions
  • Includes practical tips, tricks, and best practices for real-world development scenarios
  • Regularly updated with new content and contributions from the community

Cons of android-tips-tricks

  • Less structured format compared to the organized Q&A style of android-interview-questions
  • May be overwhelming for beginners due to the breadth of topics covered
  • Lacks specific focus on interview preparation

Code Comparison

android-tips-tricks:

// Example of a Kotlin extension function
fun View.hide() {
    this.visibility = View.GONE
}

android-interview-questions:

// Example of a Java singleton pattern
public class Singleton {
    private static Singleton instance;
    private Singleton() {}
    public static Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }
}

Both repositories provide valuable resources for Android developers, but they serve different purposes. android-tips-tricks is more suitable for ongoing learning and improving development skills, while android-interview-questions is specifically tailored for interview preparation. The choice between the two depends on the developer's immediate goals and learning preferences.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Android Interview Questions

Android Interview Questions and Answers

Android Interview Questions and Answers - Your Cheat Sheet For Android Interview

Prepared and maintained by Amit Shekhar - Coder | Teacher | Mentor | Open Source | IIT 2010-14

About me

Hi, I am Amit Shekhar, Co-Founder @ Outcome School • IIT 2010-14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.

You can connect with me on:

Join Outcome School and get high paying tech job: Outcome School

Contents - Android Interview Questions

Android Interview Questions and Answers Playlist

Kotlin Coroutines

Topics you should know in Kotlin Coroutines for Android Interview:

  • coroutines
  • suspend
  • launch, async-await, withContext
  • dispatchers
  • scope, context, job
  • lifecycleScope, viewModelScope, GlobalScope
  • suspendCoroutine, suspendCancellableCoroutine
  • coroutineScope, supervisorScope

Learn the above-mentioned from the following links:

Kotlin Flow API

Topics you should know in Kotlin Flow API for Android Interview:

  • Flow Builder, Operator, Collector
  • flowOn, dispatchers
  • Operators such as filter, map, zip, flatMapConcat, retry, debounce, distinctUntilChanged, flatMapLatest
  • Terminal operators
  • Cold Flow vs Hot Flow
  • StateFlow, SharedFlow, callbackFlow, channelFlow

Learn the above-mentioned from the following links:

Kotlin

Android Interview Questions and Answers:

Android

Android Interview Questions and Answers:

Base

  • Why does an Android App lag? - Learn from here

  • What is Context? How is it used? - Context In Android Application

  • Tell all the Android application components. - Learn from here

  • What is the project structure of an Android Application? - Learn from here

  • What is AndroidManifest.xml? - Learn from here

  • What is the Application class?

    • The Application class in Android is the base class within an Android app that contains all other components such as activities and services. The Application class, or any subclass of the Application class, is instantiated before any other class when the process for your application/package is created.

Activity and Fragment

  • Why is it recommended to use only the default constructor to create a Fragment? - Learn from video and blog

  • What is Activity and its lifecycle? - Learn from here

  • What is the difference between onCreate() and onStart() - Learn from here

  • When only onDestroy is called for an activity without onPause() and onStop()? - Learn from here

  • Why do we need to call setContentView() in onCreate() of Activity class? - Learn from here

  • What is onSaveInstanceState() and onRestoreInstanceState() in activity?

    • onSaveInstanceState() - This method is used to store data before pausing the activity.
    • onRestoreInstanceState() - This method is used to recover the saved state of an activity when the activity is recreated after destruction. So, the onRestoreInstanceState() receives the bundle that contains the instance state information.
  • What is Fragment and its lifecycle? - Learn from here

  • What are "launchMode"? - Learn from here and singleTask launchMode in Android

  • What is the difference between a Fragment and an Activity? Explain the relationship between the two. - Learn from here

  • When should you use a Fragment rather than an Activity?

    • When you have some UI components to be used across various activities
    • When multiple views can be displayed side by side just like ViewPager
  • What is the difference between FragmentPagerAdapter vs FragmentStatePagerAdapter?

    • FragmentPagerAdapter: Each fragment visited by the user will be stored in the memory but the view will be destroyed. When the page is revisited, then the view will be created not the instance of the fragment.
    • FragmentStatePagerAdapter: Here, the fragment instance will be destroyed when it is not visible to the user, except the saved state of the fragment.
  • What is the difference between adding/replacing fragment in backstack? - Learn from here

  • How would you communicate between two Fragments?

  • What is retained Fragment?

    • By default, Fragments are destroyed and recreated along with their parent Activities when a configuration change occurs. Calling setRetainInstance(true) allows us to bypass this destroy-and-recreate cycle, signaling the system to retain the current instance of the fragment when the activity is recreated.
  • What is the purpose of addToBackStack() while commiting fragment transaction?

    • By calling addToBackStack(), the replace transaction is saved to the back stack so the user can reverse the transaction and bring back the previous fragment by pressing the Back button. For more Learn from here

Views and ViewGroups

  • What is View in Android?

  • Difference between View.GONE and View.INVISIBLE? - Learn from here

  • Can you a create custom view? How?

  • What are ViewGroups and how they are different from the Views?

    • View: View objects are the basic building blocks of User Interface(UI) elements in Android. View is a simple rectangle box which responds to the user’s actions. Examples are EditText, Button, CheckBox etc. View refers to the android.view.View class, which is the base class of all UI classes.
    • ViewGroup: ViewGroup is the invisible container. It holds View and ViewGroup. For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also. ViewGroup is the base class for Layouts.
  • What is a Canvas?

  • What is a SurfaceView? - Learn from here

  • Relative Layout vs Linear Layout.

  • Tell about Constraint Layout

  • Do you know what is the view tree? How can you optimize its depth? - Learn from here

Displaying Lists of Content

  • What is the difference between ListView and RecyclerView? - Learn from here

  • How does RecyclerView work internally?

  • RecyclerView Optimization - Scrolling Performance Improvement - Learn from here

  • Optimizing Nested RecyclerView - Learn from here

  • What is SnapHelper? - Learn from here: SnapHelper

Dialogs and Toasts

Intents and Broadcasting

  • What is Intent? - Learn from here

  • What is an Implicit Intent? - Learn from here

  • What is an Explicit Intent? - Learn from here

  • What is a BroadcastReceiver? - Learn from here

  • What is a Sticky Intent?

    • Sticky Intents allows communication between a function and a service. sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). For example, if you take an intent for ACTION_BATTERY_CHANGED to get battery change events: When you call registerReceiver() for that action — even with a null BroadcastReceiver — you get the Intent that was last Broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.
  • Describe how broadcasts and intents work to be able to pass messages around your app? - Learn from here

  • What is a PendingIntent?

    • If you want someone to perform any Intent operation at future point of time on behalf of you, then we will use Pending Intent.
  • What are the different types of Broadcasts? - Learn from here

Services

Inter-process Communication

  • How can two distinct Android apps interact? - Learn from here

  • Is it possible to run an Android app in multiple processes? How? - Learn from here

  • What is AIDL? Enumerate the steps in creating a bounded service through AIDL. - Learn from here

  • What can you use for background processing in Android? - Learn from here

  • What is a ContentProvider and what is it typically used for? - Learn from here and here

Long-running Operations

  • How to run parallel tasks and get a callback when all are complete? - Long-running tasks in parallel with Kotlin Flow

  • What is ANR? How can the ANR be prevented? - Learn from here

  • What is an AsyncTask(Deprecated in API level 30) ?

  • What are the problems in AsyncTask?

  • Daemon Threads vs. User Threads - Learn from here

  • Explain Looper, Handler, and HandlerThread.

  • Android Memory Leak and Garbage Collection

Working With Multimedia Content

Data Saving

  • Jetpack DataStore Preferences - Learn from here

  • How to persist data in an Android app?

  • What is ORM? How does it work?

  • How would you preserve the Activity state during a screen rotation? - Learn from here

  • What are different ways to store data in your Android app?

  • Explain Scoped Storage in Android.

  • How to encrypt data in Android?

  • What is commit() and apply() in SharedPreferences?

    • commit() returns a boolean value of success or failure immediately by writing data synchronously.
    • apply() is asynchronous and it won't return any boolean response. If you have an apply() outstanding and you are performing commit(), then the commit() will be blocked until the apply() is not completed.

Look and Feel

  • What is a Spannable?

  • What is a SpannableString?

    • A SpannableString has immutable text, but its span information is mutable. Use a SpannableString when your text doesn't need to be changed but the styling does. Spans are ranges over the text that include styling information like color, heighliting, italics, links, etc
  • What are the best practices for using text in Android?

  • How to implement Dark mode in any application?

Memory Optimizations

  • What is the onTrimMemory() method? - Learn from here

  • How to identify and fix OutOfMemory issues?

  • How do you find memory leaks in Android applications?

Battery Life Optimizations

Supporting Different Screen Sizes

Permissions

  • What are the different protection levels in permission?

Native Programming

Android System Internal

Android Jetpack

  • What is Android Jetpack and why to use this?

  • What is a ViewModel and how is it useful? Learn: What is a ViewModel and how is it useful?

  • What are Android Architecture Components?

  • What is LiveData in Android?

  • How LiveData is different from ObservableField?

  • What is the difference between setValue and postValue in LiveData?

  • How to share ViewModel between Fragments in Android?

  • Explain WorkManager and its use cases.

  • How does ViewModel work internally?

Others

Android Libraries

Android Interview Questions and Answers:

Android Architecture

Android Interview Questions and Answers:

  • Describe the architecture of your last app.

  • Describe MVVM. - MVVM Architecture

  • MVC vs MVP vs MVVM architecture.

  • Clean Architecture

  • Software Architecture vs Software Design - Learn from here

Android System Design

Android Interview Questions and Answers:

Android Unit Testing

Android Interview Questions and Answers:

Android Tools And Technologies

Android Interview Questions and Answers:

  • What is ADB? - Learn from here

  • What is the StrictMode? - Learn from here: StrictMode

  • What is Lint? What is it used for?

  • Git.

  • Firebase. - Learn from here

  • How to measure method execution time in Android?

  • Can you access your database of SQLite Database for debugging? - Learn from here

  • What are things that we need to take care while using Proguard?

  • How to use Android Studio Memory Profiler?

  • What is Gradle?

  • APK Size Reduction.

  • How can you speed up the Gradle build?

  • About gradle build system.

  • About multiple apk for android application.

  • What is ProGuard used for? - Learn from here

  • What is obfuscation? What is it used for? What about minification?

  • How to change some parameters in an app without app update?

Java

Android Interview Questions and Answers:

OOP

  • Explain OOP Concepts.

  • Differences between abstract classes and interfaces?

    • An abstract class, is a class that contains both concrete and abstract methods (methods without implementations). An abstract method must be implemented by the abstract class sub-classes. Abstract classes cannot be instantiated and need to be extended to be used.
    • An interface is like a blueprint/contract of a class (or it may be thought of as a class with methods, but without their implementation). It contains empty methods that represent, what all of its subclasses should have in common. The subclasses provide the implementation for each of these methods. Interfaces are implemented.
  • Difference between method overloading and overriding.

  • What are the access modifiers you know? What does each one do?

    • There are four access modifiers in Java language (from strictest to the most lenient):
      1. private variables, methods, constructors or inner classes are only visible to its' containing class and its' methods. This modifier is most commonly used, for example, to allow variable access only through getters and setters or to hide underlying implementation of classes that should not be used by user and therefore maintain encapsulation. Singleton constructor is also marked private to avoid unwanted instantiation from outside.
      2. Default (no keyword is used) this modifier can be applied to classes, variables, constructors and methods and allows access from classes and methods inside the same package.
      3. protected can be used on variables, methods and constructors therefore allowing access only to subclasses and classes that are inside the same package as protected members' class.
      4. public modifier is widely-used on classes, variables, constructors and methods to grant access from any class and method anywhere. It should not be used everywhere as it implies that data marked with public is not sensitive and can not be used to harm the program.
  • Can an Interface implement another Interface?

    • Yes, an interface can implement another interface (and more than one), but it needs to use extends, rather than implements keyword. And while you can not remove methods from parent interface, you can add new ones freely to your sub-interface.
  • What is Polymorphism? What about Inheritance?

Collections and Generics

Objects and Primitives

  • How is String class implemented? Why was it made immutable?

    • There is no primitive variant of String class in Java language - all strings are just wrappers around underlying array of characters, which is declared final. This means that, once a String object is instantiated, it cannot be changed through normal tools of the language (Reflection still can mess things up horribly, because in Java no object is truly immutable). This is why String variables in classes are the first candidates to be used, when you want to override hashCode() and equals() of your class - you can be sure, that all their required contracts will be satisfied.

      Note: The String class is immutable, so that once it is created a String object cannot be changed. The String class has a number of methods, some of which will be discussed below, that appear to modify strings. Since strings are immutable, what these methods really do is create and return a new string that contains the result of the operation. (Official Java Documentation)

      This class is also unique in a sense, that, when you create an instance like this:

      String helloWorld = "Hello, World!";
      

      "Hello, World!" is called a literal and compiler creates a String object with its' value. So

      String capital = "Hello, World!".toUpperCase();
      

      is a valid statement, that, firstly, will create an object with literal value "Hello, World!" and then will create and return another object with value "HELLO, WORLD!"

    • String was made immutable to prevent malicious manipulation of data, when, for example, user login or other sensitive data is being send to a server.

  • What does it means to say that a String is immutable?

    • It means that once created, String object's char[] (its' containing value) is declared final and, therefore, it can not be changed during runtime.
  • Can you list 8 primitive types in java?

    • byte
    • short
    • int
    • long
    • float
    • double
    • char
    • boolean
  • What is the difference between an Integer and int?

    • int is a primitive data type (with boolean, byte, char, short, long, float and double), while Integer (with Boolean, Byte, Character, Short,Long, Float and Double) is a wrapper class that encapsulates primitive data type, while providing useful methods to perform different tasks with it.
  • Do objects get passed by reference or value in Java? Elaborate on that.

Java Memory Model and Garbage Collector

  • What is garbage collector? How does it work?
    • All objects are allocated on the heap area managed by the JVM. As long as an object is being referenced, the JVM considers it alive. Once an object is no longer referenced and therefore is not reachable by the application code, the garbage collector removes it and reclaims the unused memory.

Concurrency

  • What does the keyword synchronized mean?

  • What is a ThreadPoolExecutor? - ThreadPoolExecutor in Android

  • What is volatile modifier?

  • Object Level Lock vs Class Level Lock in Java - Learn from here

  • Concurrency vs Parallelism - Learn from here

  • The classes in the atomic package expose a common set of methods: get, set,, lazyset, compareAndSet, and weakCompareAndSet. Please describe them.

Exceptions

  • How does the try{}, catch{}, finally works?

  • What is the difference between a Checked Exception and an Un-Checked Exception?

Others

  • Shallow vs. Deep Copy in Java - Learn from here

  • Explain Serialization and Deserialization - Learn from here

  • What is serialization? How do you implement it?

  • What is transient modifier?

  • What are anonymous classes?

  • What is the difference between using == and .equals on an object?

  • What is the hashCode() and equals() used for?

  • When would you make an object value final?

  • What are these final, finally and finalize keywords?

  • What is the difference between "throw" and "throws" keyword in Java?

    • throws is just used to indicated which exception is to be thrown. But the throw keyword is used to throw some exception from any static block or any method.
  • What does the static word mean in Java?

    • In case of static variable it means that this variable (its' value or the object it references) spans across all instances of enclosing class (changing it in one instance affects all others), while in case of static methods it means that these methods can be invoked without an instance of their enclosing class. It is useful, for example, when you create util classes that need not be instantiated every time you want to use them.
  • Can a static method be overridden in Java?

    • While child class can override a static method with another static method with the same signature (return type can be down-casted), it is not truly overridden - it becomes "hidden", but both methods can still be accessed under right circumstances (see question about overloading/overriding above).
  • When is a static block run?

    • Code inside static block is executed only once: the first time you make an object of that class or the first time you access a static member of that class (even if you never make an object of that class).
  • Explain Reflection in Java - Learn from here

  • What is Dependency Injection?

  • Difference between StringBuffer and StringBuilder? - Learn from here

  • What is the difference between fail-fast and fail-safe iterators in Java?

  • Monitor and Synchronization

Jetpack Compose

Topics you should know in Jetpack Compose for Android Interview:

  • Compose
  • State: remember, rememberSaveable, MutableState
  • Recomposition
  • State hoisting
  • Side-effects
  • Modifier
  • Theme
  • Layout, List
  • Gestures, Animation
  • CompositionLocal

Learn the above-mentioned from the following links:

Other Topics

Android Interview Questions and Answers:

  • Describe SQLite.

  • Have you used Room-Database?

  • Can we identify the users who have uninstalled our application?

  • Android Development Best Practices. - Learn from here: Android Development Best Practices

  • React Native vs Flutter - Learn from here: React Native vs Flutter

  • What are the metrics that you should measure continuously while android application development? - Learn from here: Android App Performance Metrics

  • How to avoid API keys from check-in into VCS?

  • How does the Kotlin Multiplatform work? - Blog

  • How to use Memory Heap Dumps data?

  • How to implement Dark Theme in your app?

  • How to secure the API keys used in an Android App?

  • Tell something about memory usage in Android.

  • Explain Annotation processing.

  • How does the Android Push Notification system work? Learn from here: How does the Android Push Notification system work?

  • How to show local Notification at an exact time?

Data Structures and Algorithms

  • Android Developer should know these Data Structures for Next Interview - Check here

High-quality videos to prepare for Android Interview - Amit Shekhar YouTube Channel

High-quality blogs to prepare for Android Interview - Check here - Outcome School Blog

Found this project useful :heart:

  • Support by clicking the :star: button on the upper right of this page. :v:

You can connect with me on:

License

   Copyright (C) 2024 Amit Shekhar

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.