Android Interview
Android Interview
4) types of receivers?
ans : onreceive()
1. What is database?
First we have to convert images to 0101, then store in tablee using BLOB data type. Later
while reading the image we will read 0101 and recreate the image by using
BitMapFactory class.
ans : used to maintain relationship between tables. If a primary key of one tables comes
to other table then it becomes foreign key.
Every RDBMS should support foreign key. But by default SQLite doesn’t have support
for foreign key. To enable foreign key support below command should be issued.
ans :
c. go to inner helper class, go to onupgrade() method, use if-else condition and we can
add/ remove/ alter tables based on the version.
upgrade = create table/ drop table/ alter table in the future application releases.
[or]
fragmenttransaction.replace() [or]
fragmenttransaction.remove()
7. User clicks back button, which life cycle methods will be called for activity?
8. User clicks home button, which life cycle methods will be called for activity?
9. User is looking at screen & suddenly call comes which life cycle methods will be called
for an activity?
10. User rotates the phone, life cycle methods of an activity? [IMP]
same for virtual kyeboard up/down & language changes also. same for low memory also.
oncreate()
onapuse()
a. when user is moving away from the screen this method will be called.
b. eg: popup displayed, new screen comes, etc..
c. important data has to be saved here. eg: saving database, saving files etc..
onsaveinstancestate()
ans: For designing applications for mobile phones & tablets, we use fragments.
CoOrdinatorLayout :
AppBarLayout:
b. It is used to have parallox effect on actionbar. Parallox effect means - when user scrolls
up / down, then actionbar will be moved out of screen.
ToolBar :
c. toolbar can be placed anywhere on the screen.in olden days, action bar used to stick at
top.
TabLayout :
FloatActionButton:
NagivationView :
SnackBar :
RecyclerView :
CardView :
a) this API is used for GET request. if we want to read some data from server, we will use
this API. this is where the actual data will come from server.
a) it is used to convert/read the raw data [bits] coming in the input stream.
a) this api provides an efficient way to read data coming from server in big chunks, in
line by line fashion.
webconfig : it is a small xml file in the server, which is similar to our android manifest
xml file. this xml file contains, which URL is mapped to which Servlet this xml file also
contains, which URL is mapped to which webservice.
Servlet is the first entry point in the server, which handles incoming request.
JSP : Java server pages. It is a small java file which sits in server. Main responsibility of
JSP class is to prepare HTML content.
MVC : Model View Controller, is a design pattern used while designing web sites.
Controller -is- servlet. View -is- JSP/ JSF. Model -is- Database connection logic.
Eg: if an android application sends a request to server, it most likely hits a web service.
SOAP: Simple object access protocol. Slower compared to REST. Mostly SOAP services
uses XML format to transfer the data.
HTTP : is a common language/ protocol used over internet for communicating between
client & server systems.
1. what is service?
2. types of services?
ans : stopservice(intent);
6. what is a thread?
7. thread vs service?
1. what is ANR?
ans : if key events are not delivered in 5 seconds time limit, then O.S will show this error
popup to user.
ans : if service is not having its own thread, then service will use main thread for doing
background task. when main thread is busy in the service, it can't handle key events.
That leads to ANR.
ans : opening, inserting, reading database in activity is danger. It might lead to ANR.
but phone manifacturer can reduce it for more efficiency. but should not increase it.
Shared preferences
ans : It is a small xml file which is used to store small amount of data permenantly.
ans : getSharedPreferences()
ans : getSharedPreferences()
ans : commit() is slow, because it runs on main thread. apply() is fast, as it runs on
different thread.
op2 : use 1 pref file but use different keys/tags for each user -
et.putString("user1",...);
et.putString("user2",...);
SharedPreferences sp = getPreferences(0);
ans : xml
ans : yes
3. What is Bundle?
3. What is Serialization?
4. what is De-Serialization?
5. what is Serializable?
generated by build.gradle.
3. what is intent-filter?
9. types of services?
ans : Service does not come with default thread. Service depends on Main thread. Service
has 4 life cycle methods. Using only service will lead to ANR error. Service need to be
stopped explicitly either by stopserver [or] stopselfresult() methods.
IntentService class inherits from Service class. IntentService class comes with one
thread. Using IntentService solves ANR problem. IntentService will kill itself when there
are no more requests to start the service.
ans : abstract class can have abstract methods & concrete methods. abstract class is
partial abstraction. Abstract class should be extended. interface can have only method
declarations. interface is used to achieve pure abstraction. interface should be
implemented.
2. how will you start activity if you are expecting data back?
ans : using intent you can start activity/service/receiver. we can't start content providers
using intent. We use ContentResolver to start content provider.
5. does java support multiple inheritance?
ans : no for class, yes for interfaces. because it leads to function ambiguity.
6. how many ways we can store data in android. What all the different data storage
options available in android?
ans : <manifest>
<uses-permission>
<application>
<activity>
<intent-filter>
ans : yes.
[or]
4. User is going back from second activity to main activity, draw life cycle methods?
5. what is recyclerview?
broadcast receiver?
11.what is database.
Intent is a predefined class of android, which is used to start other activities & pass data.
ans : Activity is a component of android, it has life cycle methods. Intent is a predefined
class to start activities.
ans : 4.
Sticky Intent.
ans : It is the starting screen that gets started, when user opens the applicaiton.
not start.
1. what is android?
2. what is a fragment?
[or]
mode.
5. what is bundle?
<activity..> tags.
eg : YouTubeAndroidPlayerApi.jar
compile 'com.support.recyclerview:26+'
compile 'com.support.cardview:26+'
...material design...
...google maps...
...appcompat v7...
ans :
ans : framelayout
onpostexecute.
ans : .....
13. how do you use http request/ http response?
ans : .....
January update :
250 Android Interview Questions
For android tutorials and sample programs refer : Android tutorials point
I will keep upgrading all apps with more questions as and when required.
Note: all questions are available in android interview questions and answers -
skillgun web site also
August 8th 2014 Updates : Added Excellent set of exp questions asked in Provab,
Mindtree, and Digipay. see at the end. Especially in Provab they have asked excellent set
of questions, which I hardly seen before.
*Note: If you are experienced person appearing for android interview, request you to
update questions asked in your interview, so that I can add answers to them and will
share here with latest releases.
This list of questions are based on my interview experience with various people. Below
are the most commonly asked android interview questions. If you can answer at least
60% of these questions, that is more than enough.
Android section:
1. Activity life cycle - Can I save all my database updates in onStop()?
ans: check
2. What is the difference between this and getapplicationcontext?
ans: check
3. What is the UI response time limit in android?
ans: check
4. What is ANR?
ans: check
5. What is Bundle? How it is different from parcel?
ans: check bundle. also check android how serializable differ from parcel
6. How to write a custom adapter?
7. How to fix an android application crash? How to analyze a crash using logcat?
ans: check
8. What is a singleton class?
ans: check. also see how to create a singleton class in java
9. What is sleep mode?
ans: check
10. How to save UI states in case of configuration changes? (eg: screen orientation
changes).
11. What is a fragment? How it differs from activity?
ans: check and difference between activity and fragment
12. How to parse JSON data that is coming from a server?
13. What is 9 patch image? when to use it?
ans: check
14. What does "compatibility issue" means?
15. How will you write an application which fits both for mobiles and tablets?
ans: check - 10th question.
16. What is the Memory limit of each process in android?
ans: check
17. What kernel is used in android?
ans: check and what type of kernel is used in android
18. How to fetch a contact person number from contact application using content
provider?
ans: check
19. How to upgrade data base tables in the later versions of an application?
ans: check
20. What is the difference between dynamic receiver and static receiver? when will you
use dynamic broadcast receivers?
ans: Dynamic broadcast receivers: Android tutorial
21. What is intent, pending intent, and sticky intent?
ans: check
22. What is the difference between thread and a service?
ans: check and also what is the difference between thread and handler thread in android
23. How will you create an async task?
ans: check
24. What is a handler thread? how it is different from normal thread?
ans: check
25. What is looper, handler, and message queue?
ans: check
26. What is serialization? How serialization is different from Binders?
ans : check serialization also check how serializable differ from parcel.
27. What is aidl?
28. How to update UI from a service?
ans : Use a dynamic broadcast receiver in the activity, and send a broadcast from the
service. Once the dynamic receiver is triggered update UI from that receiver.
29. How to update UI from other thread?
ans: check
30. How to pass data between 2 components of android?
ans: use putExtras() and pass in the intent.
31. What is a binder service? how it differs from started service?
32. To write a back ground functionality in an activity, should I use a thread or service?
ans: check
33. What is ANR? What is the cause of ANR and how will you rectify this problem?
ans: check
34. How to do inter-thread communication in android, using handlers?
ans: check
35. How to create a service with single thread?
ans: check
36. Why android uses DVM, why not JVM?
ans: check what is the full form of dvm and difference between dvm and jvm why
android opted for dvm?
37. How will you display database tables in an activity? will you use gridview or
tableview? justify?