Android Developer
400+ Android Developer Interview Questions and Answers
Q1. BST Iterator Problem Statement
You are tasked with creating a class named BSTIterator
that acts as an iterator for the inorder traversal of a binary search tree. Implement the following functions:
BSTIterator(...read more
Create a BSTIterator class for inorder traversal of a binary search tree.
Implement a constructor that takes the root of the binary search tree and initializes the iterator.
Implement next() function to return the next smallest element in the inorder traversal.
Implement hasNext() function to check if there is a next element in the inorder traversal.
Traverse the binary search tree in inorder to get the desired output.
Q2. Design an photo viewing app which will show images from the disk in the list, and one item in the list should take half of the screen. (Android app design question, have to explain all the components used in it...
read moreAn Android photo viewing app with a list of images from disk, one taking half the screen.
Use RecyclerView to display the list of images
Use a custom adapter to bind the images to the RecyclerView
Use a GridLayoutManager with span count of 2 to achieve the half-screen effect
Load images from disk using a library like Glide or Picasso
Implement click listeners to handle item selection and display the selected image
Android Developer Interview Questions and Answers for Freshers
Q3. Cube Sum Pairs Problem Statement
Given a positive integer N
, find the number of ways to express N
as a sum of cubes of two integers, A
and B
, such that:
N = A^3 + B^3
Ensure you adhere to the following conditio...read more
The problem involves finding the number of ways to express a given positive integer as a sum of cubes of two integers.
Iterate through all possible values of A and B within the given constraints.
Check if A^3 + B^3 equals the given N, increment the count if true.
Handle the case where A = B separately to avoid counting duplicates.
Q4. Majority Element Problem Statement
Given an array/list 'ARR' consisting of 'N' integers, your task is to find the majority element in the array. If there is no majority element present, return -1.
Example:
Inpu...read more
Find the majority element in an array, return -1 if no majority element is present.
Iterate through the array and keep track of the count of each element using a hashmap.
Check if any element's count is greater than floor(N / 2) and return it as the majority element.
If no majority element is found, return -1.
Q5. Colorful Knapsack Problem
You are given a set of 'N' stones, each with a specific weight and color. The goal is to fill a knapsack with exactly 'M' stones, choosing one stone of each color, so that the total we...read more
The Colorful Knapsack Problem involves selecting one stone of each color to fill a knapsack with a given weight capacity, minimizing unused capacity.
Iterate through the stones and keep track of the minimum weight for each color.
Use dynamic programming to find the optimal solution by considering all possible combinations.
Handle cases where the knapsack cannot be filled under the given conditions by returning -1.
In the given example, the optimal solution is to select stones wit...read more
Q6. Find Row With Maximum 1's in a Sorted 2D Matrix
You are provided with a 2D matrix containing only the integers 0 or 1. The matrix has dimensions N x M, and each row is sorted in non-decreasing order. Your objec...read more
Find the row with the maximum number of 1's in a sorted 2D matrix.
Iterate through each row of the matrix and count the number of 1's in each row.
Keep track of the row index with the maximum number of 1's encountered so far.
Return the index of the row with the maximum number of 1's.
Share interview questions and help millions of jobseekers 🌟
Q7. Rearrange Linked List Problem Statement
Given a singly linked list in the form 'L1' -> 'L2' -> 'L3' -> ... 'Ln', your task is to rearrange the nodes to the form 'L1' -> 'Ln' -> 'L2' -> 'Ln-1', etc. You must not...read more
Rearrange the nodes of a singly linked list in a specific order without altering the data of the nodes.
Use two pointers to split the linked list into two halves.
Reverse the second half of the linked list.
Merge the two halves alternately to rearrange the nodes.
Ensure to handle cases with odd and even number of nodes separately.
Example: For input 1 -> 2 -> 3 -> 4 -> 5, the output should be 1 -> 5 -> 2 -> 4 -> 3.
Q8. Find Missing Number In String Problem Statement
You have a sequence of consecutive nonnegative integers. By appending all integers end-to-end, you formed a string S
without any separators. During this process, ...read more
Given a string of consecutive nonnegative integers without separators, find the missing integer.
Iterate through all possible splits of the string and check if the sequence is valid
If the sequence is valid, return the missing integer
Handle cases where there are multiple missing integers or the string is invalid
Android Developer Jobs
Q9. LRU Cache Design Question
Design a data structure for a Least Recently Used (LRU) cache that supports the following operations:
1. get(key)
- Return the value of the key if it exists in the cache; otherwise, re...read more
Design a Least Recently Used (LRU) cache data structure that supports get and put operations with capacity constraint.
Implement a doubly linked list to keep track of the order of keys based on their recent usage.
Use a hashmap to store key-value pairs for quick access and update.
When capacity is reached, evict the least recently used item before inserting a new item.
Update the order of keys in the linked list whenever a key is accessed or updated.
Q10. Integer to Roman Conversion
Given an integer N
, convert it to its corresponding Roman numeral representation. Roman numerals comprise seven symbols: I, V, X, L, C, D, and M.
Example:
Input:
N = 2
Output:
II
Exp...read more
Convert an integer to its corresponding Roman numeral representation.
Create a mapping of integer values to Roman numeral symbols.
Iterate through the mapping in descending order of values and build the Roman numeral representation.
Subtract the largest possible value from the integer at each step and append the corresponding Roman numeral symbol.
Repeat until the integer becomes 0.
Q11. You have to design screen in which at a time on screen 10 nearest restaurants will be shown in a list. The screen will keep adding more options while scrolling. Scroll in the list should be uninterrupted as pos...
read moreDesign a screen to show 10 nearest restaurants in a list with uninterrupted scrolling.
Use a RecyclerView to display the list of restaurants
Implement a custom adapter to populate the data in the list
Use a location service to get the user's current location
Sort the restaurants based on their distance from the user's location
Load more restaurants as the user scrolls to the end of the list
Q12. Palindrome Permutation - Problem Statement
Determine if a permutation of a given string S
can form a palindrome.
Example:
Input:
string S = "aab"
Output:
"True"
Explanation:
The permutation "aba" of the string ...read more
Check if a permutation of a string can form a palindrome.
Create a frequency map of characters in the string.
Check if at most one character has an odd frequency.
If yes, return True; otherwise, return False.
Q13. What are android components, name of activity lifecycle methods, name of fragment lifecycle methods, if one goes from 1 activity to another what are the activity lifecycle methods that are called in screen 1 an...
read moreAndroid components include activities and fragments, each with their own lifecycle methods. Transitioning from one activity to another triggers specific lifecycle methods in each screen.
Android components include activities and fragments
Activity lifecycle methods: onCreate(), onStart(), onResume(), onPause(), onStop(), onDestroy()
Fragment lifecycle methods: onAttach(), onCreate(), onCreateView(), onActivityCreated(), onStart(), onResume(), onPause(), onStop(), onDestroyView()...read more
Q14. You have application which shows list of all contacts, the Name/Numbers can be duplicated. How will you go on and do searching in this. Search term can either exist in Name or in Number.
To search for contacts with duplicate names or numbers, iterate through the list and compare each contact's name and number with the search term.
Iterate through the list of contacts
Compare the search term with each contact's name and number
Return the contacts that match the search term
Q15. Java/Android : Given an Object 'Ball'. How will you transfer this ball object from one thread to another. Same ball object pass from Thread to MainThread.
To transfer the Ball object from one thread to another, we can use Handler or AsyncTask.
Use Handler to post a Runnable to the main thread's message queue
Use AsyncTask to perform background operations and update the UI on the main thread
Pass the Ball object as a parameter or use a shared variable between threads
A waste management app to track and manage waste disposal
Include features for users to log types of waste disposed
Implement a map feature to locate nearby waste disposal facilities
Allow users to set reminders for waste collection days
Incorporate a reward system for eco-friendly waste disposal practices
Q17. Last project and what technology and architecture used in the app?
Developed a social media app using Kotlin and MVVM architecture.
Used Kotlin for coding the app
Implemented MVVM architecture for better code organization
Integrated Firebase for real-time database and authentication
Used Glide library for image loading and caching
Implemented RecyclerView for displaying posts and comments
Q18. If you were asked to make your own HashMap, how will you do it. (As it was used in the first question)
To create my own HashMap, I would use an array of linked lists to handle collisions and implement key-value pairs using a hash function.
Create an array of linked lists to store the key-value pairs
Implement a hash function to generate an index for each key
Handle collisions by adding elements to the linked list at the corresponding index
Support operations like put(key, value), get(key), and remove(key)
Q19. What is Android development
Android development is the process of creating applications for the Android operating system.
Android development involves writing code in Java or Kotlin to create mobile applications.
It includes designing user interfaces, implementing functionality, and testing the app.
Developers use Android Studio, an integrated development environment (IDE), for building Android apps.
Android apps can be published on the Google Play Store and run on various devices.
Examples of Android apps i...read more
Q20. What is use of activity creator
The activity creator is used to create instances of an activity class in Android development.
The activity creator is responsible for instantiating an activity class.
It is typically used when starting a new activity from another activity.
The activity creator can pass data to the new activity through intent extras.
It is commonly used in the onCreate() method of the calling activity.
Example: Intent intent = new Intent(this, SecondActivity.class); startActivity(intent);
Q21. Given an array, which consist of natural numbers only. The elements are in random order, tell the first missing natural number in the array. e.g 4,6,3,1,6,8 o.p - 2 1,2,3 O/P - 4
Given an array of natural numbers in random order, find the first missing natural number.
Sort the array in ascending order
Iterate through the sorted array and compare each element with its index
If the element is not equal to its index + 1, return the missing number
If all elements are in order, return the next natural number after the last element
Q22. What is json parsing, how to handle team conflicts, agile methodologies, work experience related questions
JSON parsing is the process of converting JSON data into a usable format in programming.
JSON parsing is essential for retrieving and manipulating data from APIs or databases.
It involves converting JSON strings into objects or arrays in programming languages like Java or Kotlin.
Handling team conflicts involves effective communication, active listening, and finding compromises.
Agile methodologies focus on iterative development, collaboration, and adapting to change.
Work experie...read more
Q23. What is diamond problem or why java doesn't support multiple inheritance ?
Diamond problem occurs in multiple inheritance where two superclasses have a common method.
Java doesn't support multiple inheritance to avoid diamond problem.
Diamond problem can be solved using interfaces.
Example: class A and class B both have a method named 'display', class C extends A and B, now if we call display() from C, which method will be called?
To avoid ambiguity, Java uses interfaces to achieve multiple inheritance.
Q24. what is broadcast and it's type of broadcast and what is the use of broadcast?
Broadcast is a messaging system in Android that allows communication between different components of an app or between different apps.
Broadcast is a way to send messages to multiple components or apps at once.
There are two types of broadcasts: ordered and unordered.
Ordered broadcasts are delivered to receivers in a specific order, while unordered broadcasts are delivered to all receivers at once.
Broadcasts can be used for various purposes such as sending system events, notify...read more
Q25. Dsa question- move all the zeroes to left and 1s to the right
Move all zeroes to left and ones to right in an array
Iterate through the array from both ends
Swap the elements if left is 1 and right is 0
Stop when left and right pointers meet
Use a Handler or AsyncTask to pass a Java object between threads.
Use a Handler to send messages containing the object from one thread to another.
Use AsyncTask to perform background tasks and update UI with the object on the main thread.
Q27. how does looper/handlers work internally when you pass object from one thread to another.
Looper/handlers allow passing objects between threads in Android.
Looper is a message loop that runs in a thread and processes messages from a message queue.
Handlers are used to send messages to the message queue of a looper.
When an object is passed from one thread to another using a handler, it is encapsulated in a message and added to the receiving thread's message queue.
The receiving thread's looper then processes the message and delivers it to the handler's callback method...read more
Use a thread pool to handle parallel API calls efficiently.
Implement a thread pool to manage multiple threads for downloading images concurrently.
Use a caching mechanism to store downloaded images and avoid redundant API calls.
Consider using a priority queue to prioritize important images for download.
Implement a mechanism to cancel or pause ongoing downloads if needed.
Optimize network requests by batching multiple requests together.
Q29. Do you handle the code repos and what are the third party libraries are used in your past experience.
Yes, I have experience in handling code repos and have used various third-party libraries.
I have experience in using Git for version control and have managed code repositories on GitHub and Bitbucket.
I have used third-party libraries such as Retrofit, OkHttp, Gson, and Picasso for network operations, JSON parsing, and image loading respectively.
I have also used libraries like ButterKnife and Dagger for dependency injection and RxJava for reactive programming.
I make sure to ke...read more
Q30. Design a weather app. (One image for every weather is there on a server) Take care of half downloaded image, try not to consume data of user again.
A weather app that displays images for different weather conditions, taking care of half downloaded images and minimizing data consumption.
Implement image caching to store downloaded images locally
Check if the image is already downloaded before making a network request
Use a progress bar to indicate the download status of the image
Handle cases where the download is interrupted or incomplete
Implement a mechanism to resume the download from where it left off
Optimize image loadin...read more
Q31. what is the marker interface and when and where to use interface?
Marker interface is an empty interface used to mark a class as having a particular property or behavior.
Marker interface has no methods or fields, it is used to provide metadata to the code.
It is used to indicate that a class has a certain capability or should be treated in a special way.
Examples of marker interfaces are Serializable, Cloneable, and Remote.
Interfaces are used to achieve abstraction and provide a contract for implementing classes.
Interfaces are used to achieve...read more
Q32. Explain the usage of Fragments in Android and when you might prefer using them over Activities.
Fragments are reusable UI components in Android that can be used within activities. They are preferred over activities in certain scenarios.
Fragments allow for modular and reusable UI components.
They can be used to create multi-pane layouts for tablets and larger screens.
Fragments can be added or removed dynamically at runtime.
They can retain their state during configuration changes.
Fragments can communicate with each other and with the hosting activity using interfaces.
Different launch modes for activities in Android control how the activity is launched and how it interacts with the existing activities in the back stack.
Standard: The default launch mode where a new instance of the activity is created every time it is launched.
SingleTop: If the activity is already at the top of the back stack, it will not be recreated and onNewIntent() will be called instead.
SingleTask: The activity will have a unique instance in the back stack, and if it is...read more
Q34. Puzzel : There are 4 persons (A,B,C, and D) who wants to cross a bridge in night . A takes 1 minute to cross the bridge. B takes 2 minutes to cross the bridge. C takes 5 minute to cross the bridge. D takes 10 m...
read moreMinimum time required to cross the bridge is 17 minutes.
A and B cross (2 minutes), A returns (1 minute), C and D cross (10 minutes), B returns (2 minutes), A and B cross (2 minutes).
Always send the fastest person back to minimize time.
Total time taken is the sum of all individual crossing times.
Q35. How to set equal spacing between childs of constraint layout?
To set equal spacing between childs of constraint layout, use the chain style property.
Create a chain of the views that need equal spacing using the chain style property.
Set the chain style to spread inside the constraint layout.
Adjust the margins of the views to control the spacing.
Use the layout_constraintHorizontal_chainStyle or layout_constraintVertical_chainStyle attribute to set the chain style.
Example: app:layout_constraintHorizontal_chainStyle="spread"
Q36. What is the difference between Serializable and Parcelable?
Serializable is a marker interface that allows objects to be converted into a byte stream, while Parcelable is an Android-specific interface for efficient object serialization.
Serializable is a standard Java interface, while Parcelable is an Android-specific interface.
Serializable uses reflection to serialize and deserialize objects, which can be slower and less efficient.
Parcelable requires explicit implementation of methods for serialization and deserialization, making it f...read more
Q37. How much do you know about database? MySQL or SQL Server?
I have a strong understanding of databases, including MySQL and SQL Server.
I am proficient in writing SQL queries and managing databases.
I have experience in designing and implementing database schemas.
I am familiar with database optimization techniques.
I have worked with both MySQL and SQL Server in various projects.
I understand the differences between the two and can work with either one.
Inter-Process Communication (IPC) mechanisms in Android OS allow different processes to communicate with each other.
Binder: High-performance mechanism for IPC between processes in Android. Used for communication between system services and applications.
Intent: Used for communication between components within the same application or between different applications.
Content Providers: Allow different applications to share data through a common interface.
Broadcast Receivers: Used ...read more
Deep links are URLs that take users directly to specific content within an app, while app links are URLs that open an app if it's installed, or redirect to a website if not.
Deep links are used to navigate users to a specific location within an app, bypassing the home screen.
App links are URLs that can open an app if it's installed on the device, or redirect to a website if the app is not installed.
Deep links require specific handling in the app to properly navigate to the des...read more
Q40. what is oops and its importance ?
OOPS stands for Object-Oriented Programming System. It is a programming paradigm that uses objects to represent real-world entities.
OOPS allows for modular and reusable code.
It provides a clear structure and organization to the code.
Encapsulation, inheritance, and polymorphism are key concepts in OOPS.
Example: In an Android app, each screen can be represented as an object with its own properties and behaviors.
OOPS promotes code reusability and maintainability.
Q41. You have been given a in out time log of viewers and you need to find the highest count of viewers at any given point.
To find highest count of viewers at any given point from in-out time log
Create an array of time slots with start and end time
Loop through the log and increment the count for each time slot
Track the maximum count and corresponding time slot
Return the time slot with highest count
Q42. Memory leakage, how to avoid and identify
Memory leakage can cause app crashes and slow performance. It can be avoided by proper memory management and identifying the root cause.
Avoid creating unnecessary objects
Release unused resources
Use memory profiling tools like Android Profiler
Avoid static references to objects
Use weak references when necessary
Q43. What is Dependency Injection, and how does Hilt facilitate its implementation in Android development?
Dependency Injection is a design pattern where components are given their dependencies rather than creating them.
Hilt is a dependency injection library for Android that simplifies the implementation of DI in Android apps.
Hilt generates the necessary classes for DI at compile time, reducing boilerplate code.
Hilt provides annotations like @HiltAndroidApp, @AndroidEntryPoint, and @Inject to facilitate DI in Android development.
Q44. 1)what is difference between abstract class and interface 2)how can you create JDBC application for saving the data
Answering questions on abstract class vs interface and creating JDBC application for data saving.
Abstract class can have method implementations while interface cannot
A class can implement multiple interfaces but can only inherit from one abstract class
JDBC application can be created by loading the driver, establishing connection, creating statement, executing query and closing connection
Example: Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnectio...read more
Q45. What are the different android components and concepts such as Recycler View, View Model, ANR and how do they function internally?
Android components like Recycler View, View Model, ANR are essential for building robust Android applications.
Recycler View: Efficient way to display large data sets by recycling views as they scroll off the screen.
View Model: Manages UI-related data in a lifecycle-conscious way, surviving configuration changes.
ANR (Application Not Responding): Dialog shown to the user when the main thread of an app is blocked for too long.
Understanding how these components work internally is...read more
Q46. How to know that what things people want From a phone?
To know what things people want from a phone, conduct market research, analyze user feedback, track industry trends, and consider user demographics.
Conduct market research to understand consumer preferences
Analyze user feedback from reviews, surveys, and forums
Track industry trends and technological advancements
Consider user demographics and their specific needs
Examples: larger battery life, better camera quality, faster performance
Q47. Why do we prefer constraint layout?
Constraint layout is preferred for its flexibility and efficiency.
Allows for complex layouts with minimal nesting
Supports responsive design and animations
Reduces the need for nested layouts
Improves performance by reducing layout hierarchy
Easier to maintain and update layouts
Compatible with Android Studio's Layout Editor
Q48. What is the difference b/w constraint layout & relative layout?
Constraint layout is more flexible and efficient than relative layout.
Constraint layout allows for complex layouts with fewer nested views.
It uses constraints to position and size views relative to other views or parent layout.
Relative layout positions views relative to each other or parent layout using attributes like 'above', 'below', etc.
Constraint layout is recommended for complex layouts with many views.
Relative layout is recommended for simple layouts with few views.
Q49. How to share project to client.
The project can be shared with the client through various methods such as email, cloud storage, or version control systems.
Create a build of the project
Upload the build to a cloud storage service such as Dropbox or Google Drive
Share the link to the build with the client
Use a version control system such as Git to share the project with the client
Provide instructions on how to build and run the project
Q50. On which lifecycle event, the view is attached to the Fragment?
The view is attached to the Fragment during the onAttach() lifecycle event.
The onAttach() method is called when the Fragment is associated with its host Activity.
This is the first lifecycle method called after the Fragment is created.
The onAttach() method receives the Activity as a parameter, allowing the Fragment to interact with its host.
Interview Questions of Similar Designations
Top Interview Questions for Android Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month