Common Interview Questions for Android Interns
Common Interview Questions
The answers here are solely based on personal opinions as well as interviewer feedback and other resources. Thus, all the provided answers should be used as an example only. Moreover, it is extremely important in an interview that you answer all the questions to your understanding.
- What is an Activity?
AnActivity
is an application component that usually represents a single screen with a user interface.
Extra: EachActivity
has its lifecycle so we may have more control over what we can do at different states of theActivity
through callbacks. - What is a Fragment?
We can think of aFragment
as a sub-activity, which essentially is a modular section of an application’s user interface or a behavior that can be placed in anActivity
. Therefore,Fragment
enables modular design as anActivity
can contain multipleFragments
.
Extra: The hostActivity
can add or removeFragments
at any time. Even though aFragment
has its lifecycle and callbacks, the lifecycle is closely related to the host’s lifecycle. - What are lifecycles?
Since users can navigate among different screens and applications, theActivities
andFragments
that represent those screens will have to go through different states of their lifecycles. Each state has a callback, which provides a mechanism that allows developers to execute some code when the state changes. Different callbacks at different states of a lifecycle includesonCreate()
,onRestart()
,onStart()
,onResume()
,onPause()
,onStop()
, andonDestroy()
. - What is the difference between onStart() and onResume()?
onStart()
is called when theActivity
becomes visible, whereasonResume()
is called when theActivity
is in the foreground and the user can interact with it. If we navigate away then reopen an application, bothonStart()
andonResume()
are called. On the other hand, if a dialog pops up and is dismissed, onlyonResume()
is called. - What kind of code would you put in onStart(), and what kind of code would you put in onResume()?
Imagine that we are driving,onStart()
should contain the code for starting a car (from home) such as starting the engine and releasing the hand brake. The callbackonResume()
should contain the code for resuming a car on the road (after a red light perhaps) such as releasing the foot brake and pressing the gas pedal. - What are configuration changes? How should we handle them?
Device configurations may change during runtime such as screen orientation, keyboard availability, and multi-window mode. The configuration changes may recreateActivities
orFragments
, which may affect their states. It is important that we restore (or maintain) the states and data after configuration changes occur.
Note: Please refer to this for a thorough explanation. Also, have a look at questions 15 and 16 of this post. - What are the Android Application Components?
Application components are essential building blocks for an Android application. They consist ofActivities
,Services
,Broadcast Receivers
, andContent Providers
.
Note: You should also know whatServices
,Broadcast Receivers
, andContent Providers
are. Please read questions 19 to 21 in this post for more details. - What is the difference between IntentService and JobIntentService?
Please read this awesome post to understand the difference.
Note: One of the main tasks during my first internship was migrating an Android application to Android Oreo. Thus, in my opinion, this question deserves a spot on this list. - What are the differences between ListView and RecyclerView?
Luckily, there are so many posts out there discussing the differences, such as this one.
Note: If you can only remember only one difference, just remember the ViewHolder pattern. - What are unit tests?
Unit tests are automated tests that test an isolated block of code. One of the most common frameworks for unit testing in Android is JUnit (the default framework for Android). Mockito and Espresso are also common frameworks to build on top of JUnit. - What is dependency injection?
Classes are usually dependent on having references to other classes. These required classes are called dependencies. Instead of instantiating the dependencies within a class, we may inject them into that class. For an example and a thorough explanation please read this. - What is reactive programming?
Reactive programming is a programming paradigm that uses data flow to construct the application.
Note: The definition was taken from RxJava for Android Developers. - Why use reactive programming?
Asynchronous programming is almost always listed as the first benefit of reactive programming. With the data-flow approach, every operation in the application is treated as if it is asynchronous. Thus, as long as a clear visual graph is created, it is extremely convenient to deal with asynchronous operations.
Note: This is just one of the many benefits of reactive programming, but it is a major one. RxJava for Android Developers has a whole section dedicated to explaining the benefits of reactive programming. Perhaps, interviewers may ask this question and the ones below only when you have experience working with reactive programming. - What is an Observable in RxJava?
An observable represents any object that can get data from a data source and emit a sequence of data (its states) for any registered observer. An observer is simply an object who wants to get notified when an observable emits its data. TheObservable
class in RxJava is a class that can emit any number of values and then complete or emit an error. - What is a Single, Maybe, and Completable in RxJava?
Single
is an observable that emits a value and completes or emits an error.Maybe
is similar to Single but it may not emit any value. That means it can either emit an item and complete, or emit an error, or just complete.Completable
either completes or emits an error. It does not emit any value
Bonus Questions
Each of the questions below does not have a single correct answer. These questions are there for you to express yourself and to help the interviewers understand your thought process and perspectives. Answering questions about your preference is a little bit tricky. Even though there is no single correct answer, the interviewer, subconsciously, tends to lean towards candidates who have the same preference.
- Do you prefer Java and Kotlin, and why?
Even though there is no wrong answer, don’t say that Kotlin (or Java) is better simply because someone said so. This shows that you don’t have a strong understanding and reasoning to support your choice of tools. However, do compare the language by listing the features that your preferred language has that the other doesn’t.
Note: To be honest, most employers are looking forward to hearing ‘Kotlin!’ because their team is either using Kotlin or switching to Kotlin. Nevertheless, if you have strong reasons to support Java, then go for it. - What is the most challenging technical aspect when you build the application (one of the projects you put on your resume)?
This can be a great opportunity for you to show your approach to solving difficult problems. Storytelling, in my opinion, is the best way to answer this kind of question. - Can you describe the architecture of an app you have worked on?
Simply pick one of the projects you have worked on and tell them about the architecture. Extra points will be awarded to anyone who can also describe why you (or your company) chose that architecture. - What frameworks do you use for … (e.g. dependency injections, unit tests, dealing with HTTP API)?
Similar to the above question, you can earn bonus points by telling why you (or your company) chose that framework. - How do you stay up to date with Android technology?
Just be honest.
Note: Following Android Developer is a great way to stay up-to-date
Disclaimer
The questions above are by no means the definitive guide to getting an Android internship. They are the most common questions from my experience interviewing for a few dozen Android intern positions. However, preparing for the following questions before an Android interview has helped me get most of my internships so far.
Note: The questions here are to test Android knowledge only. There is no question regarding algorithms and data structures.
Comments ()