Android Development Certificate Practice Exam: Java and XML, Exams of Technology

A practice exam for android development using java and xml. It includes multiple-choice questions covering topics such as java keywords, access modifiers, collections, exception handling, android components, ui design, data storage, and background services. Each question is followed by a correct answer and a brief explanation, making it a valuable resource for students and developers preparing for certification or seeking to enhance their knowledge of android application development. The exam covers essential concepts and best practices for building robust and efficient android applications, focusing on practical skills and theoretical understanding. It serves as a comprehensive review of key topics in android development, aiding in exam preparation and skill enhancement. The questions are designed to test understanding of fundamental concepts and their application in real-world scenarios, providing a solid foundation for further learning and development in the field.

Typology: Exams

2025/2026

Available from 12/20/2025

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 91

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Programming and Developing Android
Applications using Java and XML for Mobile
Certificate Practice Exam
**Question 1. Which keyword in Java is used to restrict a class so that it cannot be
subclassed?**
A) final
B) static
C) abstract
D) protected
Answer: A
Explanation: Declaring a class as `final` prevents other classes from extending it.
**Question 2. In Java, which access modifier makes a member visible only within its own
package and to subclasses in other packages?**
A) private
B) protected
C) public
D) default
Answer: B
Explanation: `protected` members are accessible within the same package and by subclasses
even if they are in different packages.
**Question 3. Which of the following collections maintains insertion order and allows duplicate
elements?**
A) HashSet
B) TreeSet
C) ArrayList
D) LinkedHashMap
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b

Partial preview of the text

Download Android Development Certificate Practice Exam: Java and XML and more Exams Technology in PDF only on Docsity!

Applications using Java and XML for Mobile

Certificate Practice Exam

Question 1. Which keyword in Java is used to restrict a class so that it cannot be subclassed? A) final B) static C) abstract D) protected Answer: A Explanation: Declaring a class as final prevents other classes from extending it. Question 2. In Java, which access modifier makes a member visible only within its own package and to subclasses in other packages? A) private B) protected C) public D) default Answer: B Explanation: protected members are accessible within the same package and by subclasses even if they are in different packages. Question 3. Which of the following collections maintains insertion order and allows duplicate elements? A) HashSet B) TreeSet C) ArrayList D) LinkedHashMap

Applications using Java and XML for Mobile

Certificate Practice Exam

Answer: C Explanation: ArrayList preserves the order of insertion and permits duplicates. Question 4. What is the output of the following code? String s = "Hello"; s.concat(" World"); System.out.println(s); A) Hello World B) Hello C) null D) Compilation error Answer: B Explanation: String.concat returns a new string; the original s remains unchanged. Question 5. Which interface must a class implement to be used as a target for a lambda expression that takes no arguments and returns no value? A) Callable B) Runnable C) Comparable D) Serializable Answer: B Explanation: Runnable’s run() method matches a lambda with no parameters and no return value. Question 6. In Java exception handling, which block is always executed regardless of whether an exception occurs? A) try

Applications using Java and XML for Mobile

Certificate Practice Exam

Question 9. In Android, which component runs on the main UI thread by default? A) Service B) BroadcastReceiver C) Activity D) AsyncTask.doInBackground() Answer: C Explanation: Activities (and their UI) execute on the main thread unless explicitly moved to a background thread. Question 10. Which Android SDK class provides a mapping from resource IDs to their actual values at runtime? A) Manifest.java B) BuildConfig.java C) R.java D) AndroidManifest.xml Answer: C Explanation: R.java is auto‑generated and contains integer IDs for all resources. Question 11. Which Gradle file defines the application’s compile SDK version, min SDK version, and target SDK version? A) settings.gradle B) gradle.properties C) build.gradle (Module: app) D) AndroidManifest.xml Answer: C

Applications using Java and XML for Mobile

Certificate Practice Exam

Explanation: The module‑level build.gradle contains compileSdkVersion, minSdkVersion, and targetSdkVersion. Question 12. In an Android project, where are string resources typically stored? A) res/layout/strings.xml B) res/values/strings.xml C) res/drawable/strings.xml D) assets/strings.xml Answer: B Explanation: res/values/strings.xml holds string resources for localization. Question 13. Which XML attribute defines a view’s width to match the parent’s width? A) android:layout_height="wrap_content" B) android:layout_width="match_parent" C) android:width="fill_parent" D) android:size="match_parent" Answer: B Explanation: android:layout_width="match_parent" makes the view expand to the parent’s width. Question 14. In a LinearLayout, which attribute distributes remaining space proportionally among child views? A) android:layout_gravity B) android:weightSum C) android:layout_weight

Applications using Java and XML for Mobile

Certificate Practice Exam

A) RecyclerView B) GridView C) ListView D) ScrollView Answer: C Explanation: ListView works with an Adapter to provide a scrollable list (pre‑RecyclerView). Question 18. Which method is called when a user selects an item from the options menu? A) onCreateOptionsMenu() B) onOptionsItemSelected() C) onPrepareOptionsMenu() D) onMenuItemClick() Answer: B Explanation: onOptionsItemSelected(MenuItem item) handles menu item selections. Question 19. Which Android class is used to display a short, non‑interactive message to the user? A) Snackbar B) AlertDialog C) Toast D) Notification Answer: C Explanation: Toast.makeText(...).show() shows a brief message that fades out automatically.

Applications using Java and XML for Mobile

Certificate Practice Exam

Question 20. Which preference mode makes the stored data private to the application? A) MODE_WORLD_READABLE B) MODE_WORLD_WRITEABLE C) MODE_PRIVATE D) MODE_MULTI_PROCESS Answer: C Explanation: MODE_PRIVATE (the default) restricts the preferences file to the app’s own process. Question 21. Which method of SharedPreferences.Editor writes changes to disk synchronously? A) apply() B) commit() C) putString() D) clear() Answer: B Explanation: commit() returns a boolean indicating success and blocks until the write completes. Question 22. Which Android permission is required to write to external storage? A) android.permission.READ_EXTERNAL_STORAGE B) android.permission.WRITE_EXTERNAL_STORAGE C) android.permission.INTERNET D) android.permission.ACCESS_NETWORK_STATE Answer: B

Applications using Java and XML for Mobile

Certificate Practice Exam

D) create() Answer: A Explanation: insertOrThrow(String table, String nullColumnHack, ContentValues values) inserts a row and throws an exception on failure. Question 26. In Android, which component is best suited for performing a one‑time background download that does not need user interaction? A) Activity B) Service C) BroadcastReceiver D) ContentProvider Answer: B Explanation: A Service can run in the background without a UI, suitable for downloads. Question 27. Which lifecycle method is called when a Service is started with startService()? A) onCreate() B) onStartCommand() C) onBind() D) onDestroy() Answer: B Explanation: onStartCommand() handles each call to startService(). Question 28. What is the purpose of a bound Service? A) To run indefinitely without user interaction

Applications using Java and XML for Mobile

Certificate Practice Exam

B) To provide a client‑server interface for components to interact with the Service C) To receive broadcast intents D) To display UI elements from the background Answer: B Explanation: A bound Service allows other components to bind and call its public methods. Question 29. Which manifest element registers a BroadcastReceiver to listen for the device boot completion? A) B) C) D) Answer: C Explanation: <receiver> declares a BroadcastReceiver; the appropriate intent filter would be BOOT_COMPLETED. Question 30. Which method of BroadcastReceiver is invoked when the receiver gets an intent? A) onReceive() B) onStart() C) onCreate() D) onHandleIntent() Answer: A Explanation: onReceive(Context context, Intent intent) handles incoming broadcasts.

Applications using Java and XML for Mobile

Certificate Practice Exam

Explanation: onActivityResult(int requestCode, int resultCode, Intent data) processes the returned result. Question 34. In an Activity lifecycle, which callback is guaranteed to be called before the activity becomes visible? A) onPause() B) onStart() C) onDestroy() D) onRestart() Answer: B Explanation: onStart() is invoked after onCreate() and before the activity appears on screen. Question 35. Which method is used to save transient UI state before a configuration change such as rotation? A) onPause() B) onSaveInstanceState() C) onStop() D) onDestroy() Answer: B Explanation: onSaveInstanceState(Bundle outState) stores UI state into the Bundle. Question 36. When an Activity is destroyed due to a configuration change, which method can be used to restore the saved state? A) onRestoreInstanceState() B) onStart()

Applications using Java and XML for Mobile

Certificate Practice Exam

C) onCreate() only D) onResume() Answer: A Explanation: onRestoreInstanceState(Bundle savedInstanceState) receives the Bundle after onStart(). Question 37. Which flag added to an Intent starts an Activity in a new task? A) FLAG_ACTIVITY_CLEAR_TOP B) FLAG_ACTIVITY_NEW_TASK C) FLAG_ACTIVITY_SINGLE_TOP D) FLAG_ACTIVITY_REORDER_TO_FRONT Answer: B Explanation: Intent.FLAG_ACTIVITY_NEW_TASK launches the Activity in a separate task stack. Question 38. Which Android component is designed to provide data to other applications via a defined interface? A) Service B) BroadcastReceiver C) ContentProvider D) Activity Answer: C Explanation: ContentProvider abstracts data access and can be shared across apps. Question 39. In Android, which XML element defines a style that can be applied to multiple views?

Applications using Java and XML for Mobile

Certificate Practice Exam

Question 42. Which view group stacks its children on top of each other? A) LinearLayout B) RelativeLayout C) FrameLayout D) GridLayout Answer: C Explanation: FrameLayout places children in the same frame; later children overlap earlier ones. Question 43. Which layout attribute aligns a child view to the right edge of its parent in a RelativeLayout? A) android:layout_alignParentRight="true" B) android:layout_alignParentEnd="true" C) android:layout_toRightOf="parent" D) android:gravity="right" Answer: A Explanation: layout_alignParentRight positions the view’s right side with the parent’s right side. Question 44. Which method of View can be overridden to handle a custom touch event? A) onClick() B) onTouchEvent() C) onLongClick() D) onKeyDown() Answer: B

Applications using Java and XML for Mobile

Certificate Practice Exam

Explanation: onTouchEvent(MotionEvent event) receives raw touch input. Question 45. Which Android class provides a thread pool for executing background tasks without blocking the UI? A) AsyncTask B) HandlerThread C) ExecutorService (via Executors) D) IntentService Answer: C Explanation: ExecutorService (e.g., Executors.newFixedThreadPool) manages a pool of threads. Question 46. Which method of AsyncTask runs on the UI thread after doInBackground() finishes? A) onPreExecute() B) onPostExecute() C) onProgressUpdate() D) onCancelled() Answer: B Explanation: onPostExecute(Result result) receives the background result on the UI thread. Question 47. Which permission must be declared to allow an app to access the device’s location in Android 6.0 and higher? A) android.permission.ACCESS_NETWORK_STATE B) android.permission.ACCESS_FINE_LOCATION

Applications using Java and XML for Mobile

Certificate Practice Exam

Question 50. What is the purpose of the android:exported attribute in a component declaration? A) To indicate whether the component can be launched by other apps B) To set the component’s visibility in the UI C) To define the component’s theme D) To specify the component’s permission level Answer: A Explanation: android:exported="true" allows external apps to invoke the component. Question 51. Which method of Context returns a SharedPreferences instance named “settings”? A) getPreferences("settings") B) getSharedPreferences("settings", MODE_PRIVATE) C) openFileInput("settings") D) getFileStreamPath("settings") Answer: B Explanation: getSharedPreferences(String name, int mode) retrieves a named preference file. Question 52. Which of the following is NOT a valid way to start a Service? A) startService(intent) B) bindService(intent, ServiceConnection, BIND_AUTO_CREATE) C) startActivity(intent) D) ContextCompat.startForegroundService(context, intent) Answer: C

Applications using Java and XML for Mobile

Certificate Practice Exam

Explanation: startActivity() launches an Activity, not a Service. Question 53. In Android, which layout parameter is required for a view inside a ConstraintLayout to avoid runtime errors? A) layout_width and layout_height B) layout_constraintStart_toStartOf C) layout_margin D) layout_weight Answer: A Explanation: All views must define layout_width and layout_height; constraints are optional but recommended. Question 54. Which method of Cursor moves the cursor to the first row of the result set? A) moveToFirst() B) first() C) goToFirst() D) position(0) Answer: A Explanation: cursor.moveToFirst() positions the cursor at the first row. Question 55. Which Android class can be used to parse a JSON string into a Java object? A) JSONObject B) XMLPullParser C) SAXParser