Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android interview questions and answers

1
Every application will have by default one thread. True or false?
  1. false, by default no threads available for a given application
  2. True, always any given application will have default one main thread.
  3. True, but it is not always. some times it may not have any thread.
  4. both 2 and 3
Show Answer
Share Facebook gmail Twitter
2
What is ANR (application not responding)? What is the reason for this problem and what is the solution for that problem?
  1. ANR - will occur if we are doing any other heavy functionality along with UI in single Main Thread.  If two heavy functionalities happen in single thread, it will delay response to user actions, which may irritate user, and hence stop your process.
    Solution - Run only UI components in Main Thread.
  2. ANR - will occur if we are running UI in other worker threads.Since other threads should not touch UI, it may close your application.
    Solution - never touch UI components from other than Main Thread.
  3. ANR - will occur if we are doing any other heavy functionality along with UI in single Main Thread.If two heavy functionalities happen in single thread, it will close UI because a thread can do single functionality.
    Solution - Run only UI components in Main Thread.
  4. ANR - will occur if we are doing any other heavy functionality along with UI in single Main Thread.If two heavy functionalities happen in single thread, it will delay response to user actions, which may irritate user, and hence stop your process.
    Solution - Never have two heavy functionalities in your application at a time.
Show Answer
Share Facebook gmail Twitter
3
If I have one application with activity, service, and contentprovider.  Then when I run this program how many process, threads will be created? Is it possible to run these components in more than one process?
  1. One process, one Thread, Yes it is possible to run in more than one process.
  2. One process, one thread, one application can have only one process.
  3. One process, one thread, one application can have only one process
  4. Process is not related with Application
Show Answer
Share Facebook gmail Twitter
4
Is it possible to send a message from thread-a to thread-b, if thread-b didn't prepare its looper?
  1. Yes inter thread communication is possible with out looper also
  2. if thread-a wants to send a message to thread-b, then thread-b's looper should be prepared to retrieve message send by others.
  3. if thread-a wants to send a message to thread-b, then thread-a's looper should be prepared to send message to thread-b.
  4. option 2 is correct, it is also possible with HandlerThread to have inter-thread communication.
Show Answer
Share Facebook gmail Twitter
5
How to update UI from other threads? Note : Other thread means other than main thread.
  1. It is not possible for other threads to manipulate UI.
  2. They can hold lock on that UI control, and manipulate. Holding lock is to make sure others are not touching it.
  3. Request Main Thread through inter thread communication using Handlers or runOnUiThread() function, and manipulate ui
  4. Keep the UI control which has to be shared, in a shared memory, and let all the threads manipulate it.
Show Answer
Share Facebook gmail Twitter
6
How to create a service with one thread in it?
  1. Create a service with one thread in OnCreate().
  2. Use Intent Service
  3. Both option1 and 2 are right
  4. Default with every service will one worker thread, so no need to create it.
Show Answer
Share Facebook gmail Twitter
7
By default a given process(application) will have how many threads? Who will create those threads?
  1. no threads
  2. 2 threads created by android system.
  3. 1 main thread created by androidi system
Show Answer
Share Facebook gmail Twitter
8
Does android support multitasking? How multitasking works in android, explain how to start a new task when you are already running a task?
  1. No, Android doesn't support multi tasking. But multi threading is possible.
  2. Android supports multi tasking, but only at system level, its not available for the programmers.
  3. Android supports multitasking at app level also. press home button on current task which will move it to background and then you can start new task from launcher.
  4. option 3 is right, along with that there is one more way to start a new task by using FLAG_NEW_TASK when you are starting a new activity.
Show Answer
Share Facebook gmail Twitter
9
Does android support multi threading?
  1. Yes it supports both multi tasking and multi threading.
  2. No android supports only multi tasking.
  3. Yes android supports multi threading but it wont support multi tasking
  4. none
Show Answer
Share Facebook gmail Twitter
10
What is the mechanism used by android for Inter-process-communication?
  1. Searialization
  2. Parceling
  3. Binders
  4. can use any of above mechanisms, but using serialization in android is not suggestible because it delays IPC mechanism.
Show Answer
Share Facebook gmail Twitter
11
How binder is different from serialization?
  1. Binder uses shared memory concept to do Inter process communication
  2. Serialization uses sharedmemory concept and slower than binder ipc
  3. None of them uses shared memory concept to do IPC but binders are meant for IPC for smaller devices
  4. Though Serialization is faster than Binder, it is avoided in android.
Show Answer
Share Facebook gmail Twitter
12
Is it possible to touch UI from background thread directly? What will happen if I do so?
  1. Nothing will happen, any thread can touch UI.
  2. Android follows single threaded UI model, so other threads can't touch UI.
  3. option 2 is right, but other thread can touch UI through handlers [or] runOnUIThread() methods.
  4. Android follows Multithreaded UI model, but only UI thread can touch UI.
Show Answer
Share Facebook gmail Twitter
13
How Android inter thread communication works?
  1. Not allowed in Android
  2. Can achieve through normal threads. Create 2 threads and post messages between them.
  3. Possible through only Handler Threads. Because Handler threads allows message passing mechanism through loopers.
  4. Option 3 is right, with out handler threads also one can achieve with normal threads if programmer prepares its looper programmatically.
Show Answer
Share Facebook gmail Twitter
14
What is the difference between thread and handler thread, in android?
  1. Thread will have looper and Message Queue. Default this looper will be prepared to handle incoming messages from other threads.
  2. Handler thread will have looper and MessageQueue, but looper is prepared to handle incoming messages.
  3. Both are same. No difference, but HandlerThread is sub class of Thread class.
  4. Both are same. No difference, but HandlerThread is super class of Thread class.
Show Answer
Share Facebook gmail Twitter
15
Create a thread in the activity and stop that activity, then what will happen to that thread, will it be alive or dead?
  1. it will be alive, but its priority will be least compared to thread in a service.
  2. thread created by activity will be killed immediately after activity lost its focus or life time.
  3. it will be alive for some time, and then garbage collected.
  4. it will be alive for ever, it wastes memory.
Show Answer
Share Facebook gmail Twitter
16
What is the difference between task, process, application, and thread?
  1. task, process, and application every thing is same. but thread is a part of  process.
  2. process and application are same. Task may contain 1 or more applications. thread is an internal part of a process created by OS.
  3. process and task are same. application means program. thread is part of task.
  4. process and thread are same. similarly application and thread are same.
Show Answer
Share Facebook gmail Twitter
17
How to avoid synchronization problems in threads?
  1. Use synchronized block
  2. Use Synchronized methods
  3. Use synchronized threads
  4. both option 1 and 2 is right.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
19
What is looper, message queue, and a Handler?
  1. Looper - part of any Thread to loop through message queue.
    Message Q - part of any thread, will store incoming & outgoing messages to this thread.
    Handler - communication channel between threads. we can use only one handler to communicate between any thread.
  2. Looper - part of any Thread to loop through message queue.
    Message Q - part of any thread, will store incoming messages to this thread.
    Handler - communication channel between two threads.
  3. Looper - part of any Thread to loop through message queue. default every thread will have this looper activated.
    Message Q - part of any thread, will store incoming messages to this thread.
    Handler - communication channel between two threads.
  4. Looper - part of any Thread to loop through message queue. default every thread will have this looper activated.
    Message Q - part of any thread, will store incoming messages to this thread.
    Handler - communication channel between two threads.For a given thread we should have only one handler.
Show Answer
Share Facebook gmail Twitter
20
Main thread will have a looper. True or false?
  1. yes every thread by default will have looper
  2. no only handler threads will have loopers
  3. only main thread will have looper
  4. only handler threads will have loopers, but we can prepare normal threads looper also.
Show Answer
Share Facebook gmail Twitter
Read more papers :