Android Interview Questions

Hi Guys,

Here are some Android test questions that I have compiled. Search for their answers by reading Android Docs. Post your answers in the comments. If you are too desperate for answers you can try .

  • Which class is used to handle the Bluetooth on Android?
  • Which package provide set of classes required to manage the Bluetooth on android sdk?
  • What is a sticky intent?
  • How to show a non-modal dialog/information on screen? OR What’s the purpose of Toasts.
  • What is a 9-patch image and how to benefit from it?
  • What is adb?

Following are some more generous objective questions for you.

1. Which of the following are true about PhoneStateIntentReceiver.notifyPhoneCallState?

a. notifyPhoneCallState has to be called if your application wishes to receive a notification about an incoming phone call.
b. notifyPhoneCallState is a call back function that is called when the call state changes.
c. notifyPhoneCallState is called to initiate a call from the device.
d. notifyPhoneCallState is used to send notifications about call states.
e. notifyPhoneCallState gets called when the device receives an incoming phone call.

Answer: notifyPhoneCallState has to be called if your application wishes to receive a notification about an incoming phone call.

2. Which of the following would you have to include in your project to use the APIs and classes required to access the camera on the mobile device?

a. import android.drivers;
b. import android.hardware.camera;
c. import android.camera;
d. import android.util;
e. import android.hardware;

Answer: import android.hardware

3. What is “Android-dx”?

a. A command line tool to create Android project files.
b. A framework to create unit tests for Android projects.
c. A resource editor to create user interface for Android applications.
d. A tool to generate Android byte code from .class files.
e. An emulator to execute and debug Android projects.

Answer: A tool to generate Android byte code from .class

4. Which of the following are true about enabling/disabling menu items from an Activity class?

a. onCreateOptionsMenu can be used to enable/disable some menu items in an Android application.
b. onPrepareOptionsMenu can be used to enable/disable some menu items in an Android application.
c. onShowOptionsMenu can be used to enable/disable some menu items in an Android application.
d. The menu items in an Android application cannot be disabled.

Answer: b. onPrepareOptionsMenu can be used to enable/disable some menu items in an Android application.

5. Consider the following snippet of code:

@Override
protected void onStop
{
Super.onStop();
SharedPreferences setting = getSharedPreferences(“MyPrefs”, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean(“MyBool”, true);

{some more code here}
}

Which of the following should be used at {some more code here}?

a. editor.save();
editor.close();
b. editor.save();
editor.finish();
c. editor.commit();
d. editor.save();
e. editor.close();
f. editor.finish();

Answer: editor.commit()

6. Which of the following Integrated Development Environments can be used for developing software applications for the Android platform?

a. Android IDE
b. Eclipse
c. Visual Studio 2005
d. Visual Studio 2008

Answer: Do I need to give answer to this? Go read about Android first.

7. Consider the XML fragment below, which is taken from one of the files in an Android project:

android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:text = "Some Text">

Which of the following are true about the XML fragment above?

a. It is taken from the manifest xml file of the Android project.
b. It is taken from an XML file used to define a view.
c. It is taken from the package file (.apk) of the Android project.
d. The xmlns: attribute is a compulsory attribute.
e. If this is not the outer most tag in the XML file then it need not contain the xmlns: attribute.
f. MyElement should be the name of a class derived, directly or indirectly, from the View class.

Answer: It is taken from an XML file used to define a view.
9. What is the purpose of the ContentProvider class?

a. To play rich media content files.
b. To create and publish rich media files.
c. To share data between Android applications.
d. To access the global information about an application environment.
e. To maintain global application state.

Answer: To share data between Android applications.

10. Which of the following are true?

a. startActivity and startActivityForResult can both be used to start a new activity from your activity class.
b. Only startActivityForResult can be used to launch a new activity from your activity class.
c. startActivity(myIntent); and startActivityForResult(myIntent, -1); have the same result.
d. startActivity(myIntent); and startActivityForResult(myIntent, 0); have the same result.
e. When startActivity is used to launch a new activity from your activity class then your activity class gets notified when the new activity is completed.
f. When startActivityForResult is used to launch a new activity from your activity class then your activity class gets notified when the new activity is completed.

Answer: (a) and (c), both

11. Which of the following is/are appropriate for saving the state of an Android application?

a. Activity.onFreeze()
b. Activity.onPause()
c. Activity.onStop()
d. Activity.onDestroy()

Answer: Activity.onPause()

12. Which of the following is NOT a life-cycle methods of an Activity that can be implemented to perform various operations during the lifetime of an Activity?

a. onCreate
b. onInit
c. onCompleteThaw
d. onRestart

Answer: onInit

13. Which of the following are true about Intent.CALL_ACTION and Intent.DIAL_ACTION?

a. Both of them are used to dial a phone number on the device.
b. Intent.action == Intent.CALL_ACTION is true when a phone call is received on the device.
c. Intent.action = Intent.CALL_ACTION is used when a phone number is to be dialled without showing a UI on the device.
d. Intent.action = Intent.DIAL_ACTION is used when a phone number is to be dialled without showing a UI on the device.
e. Intent.action = Intent.CALL_ACTION is used when a phone number is to be dialled without the user having to explicitly initiate the call.
f. Intent.action = Intent.DIAL_ACTION is used when a phone number is to be dialled without the user having to explicitly initiate the call.

Answer: (a), (c), (e). all three

14. What is “Android-activityCreator”?

a. A command line tool to create Android project files.
b. A framework to create unit tests for Android projects.
c. A resource editor to create user interface for Android applications.
d. A tool to generate Android byte code from .class files.
e. An emulator to execute and debug Android projects.

Answer: a. A command line tool to create Android project files.

15. Suppose MyView is a class derived from View and mView is a variable of type MyView. Which of the following should be used to display mView when the Android application is started?

a. Call setCurrentView(mView) in the startApp() of the main application class.
b. Call setContentView(mView) in the startApp() of the main application class.
c. Call setContentView(mView) in the onStart() of the main application class.
d. Call setContentView(mView) in the onCreate() of the main application class.

Answer: d. Call setContentView(mView) in the onCreate() of the main application class.

16. Which of the following programming languages can be used to develop software applications for the Android platform?

a. Java
b. C# with .NET Compact Framework for mobile devices.
c. C programming language.
d. C++ programming language.
e. Android programming language.

17. What is Android?

a. A new programming language that can be used to develop applications for mobile devices.
b. A new IDE that can be used to develop applications for mobile devices.
c. A software stack for mobile devices that includes an operating system, middleware and key applications.
d. A new mobile device developed by Google.

Answer: any guess?

18. Consider the code snippet below:

MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE);
(Some code here)
mp.start();

Which of the following should be placed at (Some code here)?

a. mp.prepare();
b. mp.prepareAsync();
c. mp.loadMedia();
d. mp.loadSource();
e. mp.loadSource();
mp.prepare();
f. No code is required at to start playback.

19. Which of the following can be used to navigate between screens of different Android applications?

a. Binder
b. Flow
c. Navigate
d. Intent
e. ApplicationContext

20. Which of the following should be used to save the unsaved data and release resources being used by an Android application?

a. Activity.onStop()
b. Activity.onPause()
c. Activity.onDestroy()
d. Activity.onShutdown()
e. Activity.onFreeze()

21. Which of the following can be accomplished by using the TelephoneNumberUtil class?

a. Save a phone number to the contacts in the phone device.
b. Retrieve a phone number from the contacts in the phone device.
c. Delete a phone number from the contacts in the phone device.
d. Format an international telephone number.
e. Setting and retrieving the call forwarding phone number on the phone device.

22. Suppose Screen1 is the main screen of an Android application MyAndroid. Now if another screen, Screen2 has to be opened from Screen1, then which of the following are true?

a. Screen2 has to be a part of MyAndroid.
b. Screen2 can exist in any other Android application installed on the device.
c. Screen2 will always be launched asynchronously.
d. Screen2 can be launched synchronously.
e. Screen2 can return a result code to Screen1 if launched with startActivity.
f. Screen2 can return a result code to Screen1 if launched with startSubActivity.

23. Select the two function calls that ]can be used to start a Service from your Android application?

a. bindService
b. startService
c. runService
d. startActivity

24. Consider the code snippet below:

public class MyReceiver extends PhoneStateIntentReceiver
{

@Override
public void onReceiveIntent(Context context, Intent intent)

{
if (intent.action == Intent.CALL_ACTION)
{

}
}
}

Assuming that notifyPhoneCallState has been called to enable MyReceiver to receive notifications about the phone call states, in which of the following cases will the code in get executed?

a. When the device receives an incoming phone call.
b. When an outgoing phone call is initiated on the device.
c. When the user presses the CALL button on the device.
d. The code in will never get executed.

25. Which of the following can be used to bind data from an SQL database to a ListView in an Android application?

a. SimpleCursor
b. SimpleCursorAdapter
c. SimpleAdapter
d. SQLiteCursor
e. SQLLiteAdapter

26. Which of the following fields of the Message class should be used to store custom message codes about the Message?

a. tag
b. what
c. arg1
d. arg2
e. userData

27. What is “Android-Positron”?

a. A command line tool to create Android project files.
b. A framework to create unit tests for Android projects.
c. A resource editor to create user interface for Android applications.
d. A tool to generate Android byte code from .class files.
e. An emulator to execute and debug Android projects.

28. Which of the following can you use to display a progress bar in an Android application?

a. ProgressBar
b. ProgressDialog
c. ProgressItem

Answer: ProgressBar, ProgressDialog

29. Which of the following is the immediate base class for Activity and Service classes?

a. Application
b. ApplicationContext
c. Context
d. Component
e. Object

Answer: Context

30. Which of the following can be used to handle commands from menu items in an Android application?

a. commandAction
b. onMenuItem
c. onMenuItemSelected
d. onMenuItemClicked
e. onOptionsItemSelected

Answer: onOptionsItemSelected

31. What is the ListActivity class used for?

a. Create a view to display a list of items from a data source.
b. List all the activities currently running on the Android device.
c. List all the activites that are installed on the Android device.
d. List the activities whose IntentFilters match with a particular Intent type.

32. Which of the following can you use to display an HTML web page in an Android application?

a. WebBrowser
b. BrowserView
c. WebView
d. Browser
e. HtmlView

Answer: WebView

33. Which of the following is the parent class for the main application class in an Android application that has a user interface?

a. MIDLet
b. AndroidApp
c. Activity
d. AppLet
e. Application

Answer: c. Activity

34. What is the interface Spannable used for?

a. Manipulate text that can span across multiple pages.
b. Manipulate text that can span across multiple TextView windows.
c. This is the interface for text to which markup objects can be attached and detached.
d. String parsing.

Answer: c. This is the interface for text to which markup objects can be attached and detached.

35. Which of the following are UI elements that you can use in a window in an Android application?

a. TextBox
b. TextView
c. TextField
d. TextElement
e. EditText
f. RichText

Answer: TextView, EditText

36. Which of the following are true?

a. Both startActivity and startSubActivity start an activity synchronously.
b. Both startActivity and startActivityForResults start an activity asynchronously.
c. startActivity is an asynchronous call, but startSubActivity is synchronous.
d. startActivity is a synchronous call, but startSubActivity is asynchronous.

Answer: a. Both startActivity and startSubActivity start an activity synchronously.

2 thoughts on “Android Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>