Pages

Thursday, March 17, 2016

Android Programming Test 2016 | upwork test Answer

1. Which of the following are UI elements that you can use in a window in an Android application?
Answers:
  1. TextBox
  2. TextView
  3. TextField
  4. TextElement
  5. EditText
  6. RichText
2. What is the correct way to fix if checking the status of the GPS_PROVIDER throws SecurityException?
Answers:
  1. request permission for ACCESS_COARSE_LOCATION
  2. request permission for ACCESS_FINE_LOCATION
  3. request permission for INSTALL_LOCATION_PROVIDER
  4. None of the above
3. Which of the following is not Content Provider?
Answers:
  1. Contacts
  2. Contacts
  3. Shared Preferences
  4. MediaStore
  5. Bookmarks
  6. Settings
4. Which of the following statements are correct with regards to signing applications?
a) All applications must be signed.
b) No certificate authority is needed.
c) When releasing application special debug key that is created by the Android SDK build tools can be used.
Answers:
  1. a) and b) are true
  2. a) and c) are true
  3. b) and c) are true
  4. all statements are true
5. What does the following code do?
SensorManager mgr = (SensorManager) getSystemService(SENSOR_SERVICE);
List<Sensor> sensors = mgr.getSensorList(Sensor.TYPE_ALL);
for (Sensor sensor : sensors) {
System.out.println(“”+sensor.getName());
}
Answers:
  1. prints names of all available sensors in device
  2. prints names of all available sensor types in device
  3. prints names of all sensors which are not available
  4. none of above
6. What does the following code do?
try {
String token = GoogleAuthUtil.getToken(this, email, “https://www.googleapis.com/auth/devstorage.read_only”);
System.out.println(token);
} catch (IOException e) {
System.out.println(“IOException”);
} catch (UserRecoverableAuthException e) {
System.out.println(“UserRecoverableAuthException”);
} catch (GoogleAuthException e) {
System.out.println(“GoogleAuthException”);
}
Answers:
  1. prints token
  2. prints IOException
  3. prints UserRecoverableAuthException
  4. prints GoogleAuthException
7. Which of the following is correct to use for data transfer regularly and efficiently, but not instantaneously?
Answers:
  1. AsyncTask
  2. IntentService
  3. Sync adapters
  4. All of these
8. What is the ListActivity class used for?
Answers:
  1. Create a view to display a list of items from a data source.
  2. List all the activities currently running on the Android device.
  3. List all the activites that are installed on the Android device.
  4. List the activities whose IntentFilters match with a particular Intent type.
9. Using a content provider, which of the following operations are able to perform?
a) create
b) read
c) update
d) delete
Answers:
  1. a, b and c
  2. b, c and d
  3. all of these
  4. none of these
10. Which of the following widgets helps to embed images in activities?
Answers:
  1. ImageView
  2. ImageButton
  3. both of above
  4. none of these
11. What is the best way of opening camera as sub-activity?
Answers:
  1. Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivity(takePictureIntent);
  2. Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, 1); }
  3. Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(takePictureIntent, 1);
  4. Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { startActivityForResult(takePictureIntent, -1); }
12. What is the correct way to restrict app visibility on Google Play to devices that have a camera?
Answers:
  1. <uses-feature android:name=”android.hardware.camera”/>
  2. <uses-feature android:name=”android.hardware.camera” android:required=”true” />
  3. <uses-feature android:name=”android.hardware.camera.front” android:required=”true” />
  4. <uses-permission android:name=”android.permission.CAMERA”/>
13. Which of the following sensors is only hardware-based?
Answers:
  1. linear acceleration sensor
  2. gravity sensor
  3. rotation vector sensor
  4. accelerometer sensor
14. Which of the following formats is not supported in Android?
Answers:
  1. MP4
  2. MPEG
  3. AVI
  4. MIDI
15. Which of the following permissions and configurations must be added in manifest file for implementing GCM Client?
A) com.google.android.c2dm.permission.RECEIVE
B) android.permission.INTERNET
C) android.permission.GET_ACCOUNTS
D) android.permission.WAKE_LOCK
E) applicationPackage + “.permission.C2D_MESSAGE”
F) A receiver for com.google.android.c2dm.intent.RECEIVE, with the category set as applicationPackage. The receiver should require the com.google.android.c2dm.SEND permission
Answers:
  1. A, B, C and D
  2. C, D, E and F
  3. A, B, E and F
  4. all of these
16. Which of the following permissons is needed to perform the network operations through internet?
a) INTERNET
b) ACCESS_NETWORK_STATE
Answers:
  1. a
  2. b
  3. both
  4. none
17. 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 <some more code here>?
Answers:
  1. editor.save(); editor.close();
  2. editor.save(); editor.finish();
  3. editor.commit();
  4. editor.save();
  5. editor.close();
  6. editor.finish();
18. What does the following statement define?
It provides query(), insert(), update(), and delete() methods for accessing data from a content provider and invokes identically-named methods on an instance of a concrete content provider.
Answers:
  1. CursorLoader
  2. ContentResolver
  3. ContentProvider
  4. Loader
19. What is the advantage of using AsyncTaskLoader instead of AsyncTask?
Answers:
  1. a bit easier to work with
  2. the possibility easily update progress bar
  3. no comparison, because it implements completely different functionality
  4. less work with the configuration of applicationM
20. What does the following code do?
public boolean isOnline() {
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return (networkInfo != null && networkInfo.isConnected());
}
Answers:
  1. checking Network connection.
  2. checking only WIFI network connectivity.
  3. checking only Bluetooth data connection.
  4. checking only Ethernet data connection
21. Which of the following statements are correct with regards to running of the Sync Adapter?
A) Running sync adapter in response to a user request.
B) Running sync adapter periodically by setting a period of time to wait between runs, or by running it at certain times of the day, or both.
Answers:
  1. Statement A is true, while Statement B is false.
  2. Statement B is true, while Statement A is false.
  3. Both statements are true.
  4. Both statements are false.
22. Which of the following statements are correct with regards to calling place GoogleAuthUtil.getToken()?
A) call getToken() on the UI thread
B) call getToken() on AsyncTask
Answers:
  1. Statement A is true, while Statement B is false.
  2. Statement B is true, while Statement A is false.
  3. Both statements are true.
  4. Both statements are false.
23. Which of the following protocols are provided by Google for GCM Connection Servers?
A) HTTP
B) XMPP
C) SOAP
D) RMI
Answers:
  1. A and B
  2. A, B, C
  3. C, D
  4. all of these
24. Which of the following 4 classes does not relate to others?
ApplicationInfo, SyncInfo, ActivityInfo, PackageInfo
Answers:
  1. ApplicationInfo
  2. SyncInfo
  3. ActivityInfo
  4. PackageInfo
25. Which of the following are valid ways to deploy an Android application to a device?
Answers:
  • Using the “adb install /path/to/apk” command from the command prompt/terminal, when USB Debugging Mode is enabled in the device.
  • Exporting and signing the package, then browsing it to install.
  • Launching the application from an IDE, when USB Debugging Mode is enabled in the device.
  • All of these.
26. Which of the following classes is not used in working with database?
Answers:
  1. SQLiteOpenHelper
  2. SQLiteDatabase
  3. ContentProvider
  4. DatabaseHelper
27. Consider the XML fragment below, which is taken from one of the files in an Android project:
<MyElement xmlns:”http://schemas.androd.com/apk/res/android”
android:layout_width = “fill_parent”
android:layout_height = “fill_parent”
android:text = “Some Text”>
</MyElement>
Which of the following are true about the XML fragment above?
Answers:
  1. It is taken from the manifest XML file of the Android project.
  2. It is taken from an XML file used to define a view.
  3. It is taken from the package file (.apk) of the Android project.
  4. The xmlns: attribute is a compulsory attribute.
  5. If this is not the outer most tag in the XML file then it need not contain the xmlns: attribute.
  6. MyElement should be the name of a class derived, directly or indirectly, from the View class.
28. Which of the following statement is correct regarding StrictMode?
Answers:
  1. StrictMode detects improper layouts
  2. StrictMode detects operation which blocks UI
  3. StrictMode detects the speed of the connection
  4. All of the above
29. 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>?
Answers:
  1. mp.prepare();
  2. mp.prepareAsync();
  3. mp.loadMedia();
  4. mp.loadSource();
  5. mp.loadSource(); mp.prepare();
  6. No code is required at <Some code here> to start playback.
30. 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?
Answers:
  1. When the device receives an incoming phone call.
  2. When an outgoing phone call is initiated on the device.
  3. When the user presses the CALL button on the device.
  4. The code in will never get executed.
31. Which of the following are true about enabling/disabling menu items from an Activity class?
Answers:
  1. onCreateOptionsMenu can be used to enable/disable some menu items in an Android application.
  2. onPrepareOptionsMenu can be used to enable/disable some menu items in an Android application.
  3. onShowOptionsMenu can be used to enable/disable some menu items in an Android application.
  4. The menu items in an Android application cannot be disabled.
32. Which of the following should be used to save the unsaved data and release resources being used by an Android application?
Answers:
  1. Activity.onStop()
  2. Activity.onPause()
  3. Activity.onDestroy()
  4. Activity.onShutdown()
  5. Activity.onFreeze()
33. Which of the following statements are correct with regards to publishing updates of apps on Google Play?
Answers:
  1. The android:versionCode attribute in the manifest file must be incremented and the APK file must be signed with the same private key.
  2. The android:versionCode attribute in the manifest file must be same and the APK file must be signed with the same private key.
  3. The android:versionCode attribute in the manifest file must be incremented and the APK file must be signed with the new private key.
  4. The android:versionCode attribute in the manifest file must be same and the APK file must be signed with the new private key.
34. Which of the following would you have to include in your project to use the SimpleAdapter class?
Answers:
  1. import android.content;
  2. import android.widget;
  3. import android.database;
  4. import android.database.sqlite;
  5. import android.util;
35. Which of the following is/are appropriate for saving the state of an Android application?
Answers:
  1. Activity.onFreeze()
  2. Activity.onPause()
  3. Activity.onStop()
  4. Activity.onDestroy()
36. Which of the following is the parent class for the main application class in an Android application that has a user interface?
Answers:
  1. MIDLet
  2. AndroidApp
  3. Activity
  4. AppLet
  5. Application
37. Which of the following can be used to bind data from an SQL database to a ListView in an Android application?
Answers:
  1. SimpleCursor
  2. SimpleCursorAdapter
  3. SimpleAdapter
  4. SQLiteCursor
  5. SQLLiteAdapter
38. 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>?
Answers:
  1. mp.prepare();
  2. mp.prepareAsync();
  3. mp.loadMedia();
  4. mp.loadSource();
  5. mp.loadSource(); mp.prepare();
  6. No code is required at <Some code here> to start playback.
39. Which of the following packages provide the classes required to manage the Bluetooth functionality on an Android device?
Answers:
  1. android.hardware
  2. android.bluetooth
  3. android.bluez
  4. org.bluez
40. Which of the following can be accomplished by using the TelephoneNumberUtil class?
Answers:
  1. Save a phone number to the contacts in the phone device.
  2. Retrieve a phone number from the contacts in the phone device.
  3. Delete a phone number from the contacts in the phone device.
  4. Format an international telephone number.
  5. Setting and retrieving the call forwarding phone number on the phone device.
41. Which of the following is the best way to request user permission if an Android application receives location updates from both NETWORK_PROVIDER and GPS_PROVIDER?
Answers:
  1. Adding this line to the Android manifest file: <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” />
  2. Adding these two lines to the Android manifest file: <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” /> <uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION” />
  3. Adding this line to the Android manifest file: <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” />
  4. Adding this line to the Android manifest file: <uses-permission android:name=”android.permission.CONTROL_LOCATION_UPDATES” />
42. Which of the following are true about PhoneStateIntentReceiver.notifyPhoneCallState?
Answers:
  1. notifyPhoneCallState has to be called if your application wishes to receive a notification about an incoming phone call.
  2. notifyPhoneCallState is a call back function that is called when the call state changes.
  3. notifyPhoneCallState is called to initiate a call from the device.
  4. notifyPhoneCallState is used to send notifications about call states.
  5. notifyPhoneCallState gets called when the device receives an incoming phone call.
43. Which of the following statements are correct with regards to Content Providers?
A) A content provider allows applications to access data.
B) A content provider must be declared in the AndroidManifest.xml file.
Answers:
  1. Statement A is true, while Statement B is false.
  2. Statement B is true, while Statement A is false.
  3. Both statements are true.
  4. Both statements are false.
44. Which of the following functions will return all available Content Providers?
Answers:
  1. List<ProviderInfo> returnList = new ArrayList<ProvderInfo>(); for (PackageInfo pack : getPackageManager().getInstalledPackages(PackageManager.GET_PROVIDERS)) { ProviderInfo[] providers = pack.providers; if (providers != null) { returnList.addAll(Arrays.asList(providers)); } } return returnList;
  2. return getContext().getPackageManager().queryContentProviders(“com.google”, Process.myUid(), 0);
  3. List<ActivityInfo> returnList = new ArrayList<ActivityInfo>(); for (PackageInfo pack : getPackageManager().getInstalledPackages(PackageManager.GET_RECEIVERS)) { ActivityInfo[] providers = pack.receivers; if (providers != null) { returnList.addAll(Arrays.asList(providers)); } } return returnList;
  4. None of these.
45. What is the purpose of the ContentProvider class?
Answers:
  1. To play rich media content files.
  2. To create and publish rich media files.
  3. To share data between Android applications.
  4. To access the global information about an application environment.
  5. To maintain global application state.
46. Which of the following are true?
Answers:
  1. Both startActivity and startSubActivity start an activity synchronously.
  2. Both startActivity and startActivityForResults start an activity asynchronously.
  3. startActivity is an asynchronous call, but startSubActivity is synchronous.
  4. startActivity is a synchronous call, but startSubActivity is asynchronous.
47. Which of the following is the immediate base class for Activity and Service classes?
Answers:
  1. Application
  2. ApplicationContext
  3. Context
  4. Component
  5. Object
48. Which of the following are classes that can be used to handle the Bluetooth functionality on a device?
Answers:
  1. Adapte
  2. Manage
  3. Matche
  4. BluetoothAdapte
49. How many expansion files can an APK file have? Select all correct options.
Answers:
  1. one
  2. two
  3. three
  4. four
50. Which of the following are Android build modes?
Answers:
  1. Debug mode
  2. Release mode
  3. Production mode
  4. Development mode
51. What is “Android-dx”?
Answers:
  1. A command line tool to create Android project files.
  2. A framework to create unit tests for Android projects.
  3. A resource editor to create user interface for Android applications.
  4. A tool to generate Android byte code from .class files.
  5. An emulator to execute and debug Android projects.
52. Consider the XML fragment below, which is taken from one of the files in an Android project:
<MyElement xmlns:”http://schemas.androd.com/apk/res/android”
android:layout_width = “fill_parent”
android:layout_height = “fill_parent”
android:text = “Some Text”>
</MyElement>
Which of the following are true about the XML fragment above?
Answers:
  1. It is taken from the manifest xml file of the Android project.
  2. It is taken from an XML file used to define a view.
  3. It is taken from the package file (.apk) of the Android project.
  4. The xmlns: attribute is a compulsory attribute.
  5. If this is not the outer most tag in the XML file then it need not contain the xmlns: attribute.
  6. MyElement should be the name of a class derived, directly or indirectly, from the View class.
53. Which of the following fields of the Message class should be used to store custom message codes about the Message?
Answers:
  1. tag
  2. what
  3. arg1
  4. arg2
  5. userData
54. 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?
Answers:
  1. Screen2 has to be a part of MyAndroid.
  2. Screen2 can exist in any other Android application installed on the device.
  3. Screen2 will always be launched asynchronously.
  4. Screen2 can be launched synchronously.
  5. Screen2 can return a result code to Screen1 if launched with startActivity.
  6. Screen2 can return a result code to Screen1 if launched with startActivityForResult.
55. Select the two function calls that can be used to start a Service from your Android application?
Answers:
  1. bindService
  2. startService
  3. runService
  4. startActivity
56. Which of the following Integrated Development Environments can be used for developing software applications for the Android platform?
Answers:
  1. Android IDE
  2. Eclipse
  3. Visual Studio 2005
  4. Visual Studio 2008
57. Which of the following can you use to display an HTML web page in an Android application?
Answers:
  1. WebBrowser
  2. BrowserView
  3. WebView
  4. Browser
  5. HtmlView
58. Consider the following snippet of code:
<font size =2>
@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 <some more code here>?
</font
Answers:
  1. editor.save(); editor.close();
  2. editor.save(); editor.finish();
  3. editor.commit();
  4. editor.save();
  5. editor.close();
  6. editor.finish();
59. What is “Android-Positron”?
Answers:
  1. A command line tool to create Android project files.
  2. A framework to create unit tests for Android projects.
  3. A resource editor to create user interface for Android applications.
  4. A tool to generate Android byte code from .class files.
  5. An emulator to execute and debug Android projects.
60. Which of the following can you use to add items to the screen menu?
Answers:
  1. Activity.onCreate
  2. Activity.onCreateOptionsMenu
  3. Constructor of the Activity class.
  4. Activity.onCreateMenu
  5. Activity.onStart
  6. Activity.onPrepareOptionsMenu
61. 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?
Answers:
  1. onCreate
  2. onInit
  3. onCompleteThaw
  4. onRestart
62. What is the interface Spannable used for?
Answers:
  1. Manipulate text that can span across multiple pages.
  2. Manipulate text that can span across multiple TextView windows.
  3. This is the interface for text to which markup objects can be attached and detached.
  4. String parsing.
63. What is correct regarding GCM – Google Cloud Messaging service?
Answers:
  1. It does server to device communication.
  2. It does device to server communication.
  3. It does device to server communication and vice versa.
  4. It does device to device communication.
64. Which of the following procedures will get the package name of an APK file?
Answers:
  1. Looking for the package attribute’s value of the <manifest> element in the manifest file.
  2. Executing the command, “pm list packages -f”, in the ADB shell.
  3. Programmatically, using PackageManager in an installed Android app.
  4. Using the AAPT platform tool, “aapt dump badging apkName.apk”.
65. What is the maximum supported file size for a single APK file (excluding expansion packages) in the Google Play Store?
Answers:
  1. 50MB
  2. 2GB
  3. 30MB
  4. unlimited
66. What is Android?
Answers:
  1. A new programming language that can be used to develop applications for mobile devices.
  2. A new IDE that can be used to develop applications for mobile devices.
  3. A software stack for mobile devices that includes an operating system, middleware and key applications.
  4. A new mobile device developed by Google.
67. Which of the following can be used to navigate between screens of different Android applications?
Answers:
  1. Binde
  2. Flow
  3. Navigate
  4. Intent
  5. ApplicationContext
68. Which of the following are valid features that you can request using requestWindowFeature?
Answers:
  1. FEATURE_NO_TITLE
  2. FEATURE_NO_ICON
  3. FEATURE_RIGHT_ICON
  4. FEATURE_NO_MENU
  5. FEATURE_TRANSPARENT_WINDOW
69. Which of the following are true?
Answers:
  1. startActivity and startActivityForResult can both be used to start a new activity from your activity class.
  2. Only startActivityForResult can be used to launch a new activity from your activity class.
  3. startActivity(myIntent); and startActivityForResult(myIntent, -1); have the same result.
  4. startActivity(myIntent); and startActivityForResult(myIntent, 0); have the same result.
  5. 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.
  6. 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.
70. Which of the following can you use to display a progress bar in an Android application?
Answers:
  1. ProgressBa
  2. ProgressDialog
  3. ProgressItem
71. Which of the following can be used to handle commands from menu items in an Android application?
Answers:
  1. commandAction
  2. onMenuItem
  3. onMenuItemSelected
  4. onMenuItemClicked
  5. onOptionsItemSelected
72. Fill in the blank:
Once an app is published, the ________ cannot be changed. It should be unique for each APK.
Answers:
  1. private key
  2. package name
  3. main activity
  4. APK file name
73. Which of the following attributes in the manifest file defines version information of an application for the Google Play Store (as opposed to defining version information for display to users)?
Answers:
  1. android:versionCode
  2. android:versionName
  3. android:targetSdkVersion
  4. android:maxSdkVersion
74. Which of the following are true about Intent.CALL_ACTION and Intent.DIAL_ACTION?
Answers:
  1. Both of them are used to dial a phone number on the device.
  2. Intent.action == Intent.CALL_ACTION is true when a phone call is received on the device.
  3. Intent.action = Intent.CALL_ACTION is used when a phone number is to be dialled without showing a UI on the device.
  4. Intent.action = Intent.DIAL_ACTION is used when a phone number is to be dialled without showing a UI on the device.
  5. Intent.action = Intent.CALL_ACTION is used when a phone number is to be dialled without the user having to explicitly initiate the call.
  6. Intent.action = Intent.DIAL_ACTION is used when a phone number is to be dialled without the user having to explicitly initiate the call.
75. 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?
Answers:
  1. Call setCurrentView(mView) in the startApp() of the main application class.
  2. Call setContentView(mView) in the startApp() of the main application class.
  3. Call setContentView(mView) in the onStart() of the main application class.
  4. Call setContentView(mView) in the onCreate() of the main application class.
76. Which of the following programming languages can be used to develop software applications for the Android platform?
Answers:
  1. Java
  2. C# with .NET Compact Framework for mobile devices.
  3. C programming language.
  4. Android programming language.
77. 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?
Answers:
  1. import android.drivers;
  2. import android.hardware.camera;
  3. import android.camera;
  4. import android.util;
  5. import android.hardware;
78. What is “Android-activityCreator”?
Answers:
  1. A command line tool to create Android project files.
  2. A framework to create unit tests for Android projects.
  3. A resource editor to create user interface for Android applications.
  4. A tool to generate Android byte code from .class files.
  5. An emulator to execute and debug Android projects.
79. What is the maximum supported size for a single expansion file in the Google Play Store?
Answers:
  1. 50MB
  2. 2GB
  3. 30MB
  4. unlimited
80. Which of the f

No comments:

Post a Comment