Android Certified Application Developer (AND-X01) — Questions and Answers
Question 1: What is Java bytecode compiled into while developing an Android app?
- Dalvik byte code (Correct answer)
- Java class files
- source code
- Java source code
Correct answer: Dalvik byte code
During Android app development, Java source code is first compiled into standard Java bytecode (.class files). This Java bytecode is then further processed by the Dex Compiler (historically `dx`, now `d8`) into Dalvik bytecode (.dex files). This Dalvik bytecode is optimized for the Android Runtime (ART) or the older Dalvik virtual machine, which executes the app on the device.
Question 2: What does the Android vitals metric 'ANR rate' measure?
- The rate at which background processes are killed by the OS
- The average number of crashes per session
- The percentage of daily active users who experienced an Application Not Responding dialog (Correct answer)
- The percentage of sessions with network request failures
Correct answer: The percentage of daily active users who experienced an Application Not Responding dialog
ANR (Application Not Responding) rate in Android vitals measures the proportion of daily active users who encountered an ANR dialog, a key indicator of main-thread blocking issues.
Question 3: Which Android API is used to detect if the device is rooted or compromised?
- SafetyNet Attestation API (deprecated)
- Root Checker API
- Play Integrity API
- Both A and B (Correct answer)
Correct answer: Both A and B
Both the Play Integrity API (current) and the deprecated SafetyNet Attestation API assess device integrity and detect rooting or tampering.
Question 4: What does the FLAG_SECURE window flag do in Android?
- Prevents screenshots from being saved
- Locks the screen
- Encrypts window data
- Prevents the screen content from appearing in screenshots and screen recordings (Correct answer)
Correct answer: Prevents the screen content from appearing in screenshots and screen recordings
FLAG_SECURE marks an Activity's window as secure, preventing its content from appearing in screenshots, recent apps thumbnails, and screen recordings.
Question 5: What does ProGuard/R8 do in Android release builds?
- Validates permissions
- Encrypts APK resources
- Shrinks, obfuscates, and optimizes code (Correct answer)
- Signs the APK
Correct answer: Shrinks, obfuscates, and optimizes code
ProGuard/R8 removes unused code, renames classes and methods to short names, and optimizes bytecode to reduce APK size and hinder reverse engineering.
Question 6: Which method is used to get or create an instance of a Room database?
- RoomDatabase.create()
- Room.getInstance()
- RoomDatabase.build()
- Room.databaseBuilder() (Correct answer)
Correct answer: Room.databaseBuilder()
Room.databaseBuilder() creates or opens a Room database with the specified context, class, and database name.
Question 7: What does the LiveData class guarantee that a plain observable does not?
- Lifecycle-aware delivery, so observers only receive updates while active (Correct answer)
- Observers are notified even after onDestroy()
- Updates are delivered on a background thread
- Values are persisted across reboots
Correct answer: Lifecycle-aware delivery, so observers only receive updates while active
LiveData respects the observer's lifecycle, delivering data only to started or resumed components and auto-removing destroyed ones.
Question 8: Which library is used for mocking dependencies in Android unit tests?
- Robolectric
- Espresso
- JUnit
- Mockito (Correct answer)
Correct answer: Mockito
Mockito is a popular mocking framework that creates fake implementations of dependencies, allowing you to isolate the code under test.
Question 9: Which component should be used to expose an app's data to other applications in a secure, structured way?
- Fragment
- BroadcastReceiver
- ContentProvider (Correct answer)
- Service
Correct answer: ContentProvider
ContentProvider is the standard component for sharing structured data across app boundaries with permission control.
Question 10: Where are Android unit tests located in a project structure?
- test/unit/java
- src/androidTest/java
- src/main/test
- src/test/java (Correct answer)
Correct answer: src/test/java
Unit tests are placed in the src/test/java directory and run locally on the JVM without Android framework dependencies.
Question 11: Which method should you override to handle the result of a runtime permission request?
- onPermissionResult
- onPermissionGranted
- onRequestPermissionsResult (Correct answer)
- onActivityResult
Correct answer: onRequestPermissionsResult
onRequestPermissionsResult is called after the user responds to a permission request dialog, providing the granted or denied results.
Question 12: What is the purpose of SharedPreferences in Android?
- To store large files
- To share data between apps
- To manage user accounts
- To store small amounts of primitive key-value data persistently (Correct answer)
Correct answer: To store small amounts of primitive key-value data persistently
SharedPreferences provides a mechanism for storing and retrieving small amounts of primitive data as key-value pairs that persist across app sessions.
Question 13: What happens to data in getCacheDir() when the device runs low on storage?
- The app crashes
- Nothing happens
- The system may delete cache files automatically (Correct answer)
- The data is moved to external storage
Correct answer: The system may delete cache files automatically
Files in the cache directory may be deleted by the system when storage is low, so apps should not rely on them for critical data.
Question 14: Which layout in Android arranges child views in a single row or column?
- LinearLayout (Correct answer)
- RelativeLayout
- FrameLayout
- ConstraintLayout
Correct answer: LinearLayout
LinearLayout arranges its child views sequentially in either a horizontal or vertical direction.
Question 15: What is the primary purpose of the AndroidManifest.xml file?
- Storing user preferences at runtime
- Defining Gradle build dependencies
- Holding string translations
- Declaring app components, permissions, and metadata to the system (Correct answer)
Correct answer: Declaring app components, permissions, and metadata to the system
The manifest declares Activities, Services, permissions, and other essential app information to the Android system.
Question 16: Which Room annotation is used to define data access methods?
- @Database
- @Repository
- @Dao (Correct answer)
- @Query
Correct answer: @Dao
@Dao marks an interface or abstract class as a Data Access Object, which contains methods for interacting with the database.
Question 17: What is the principle of least privilege in Android development?
- Giving users the least access to app features
- Requesting only the permissions absolutely necessary for the app to function (Correct answer)
- Using the lowest API level possible
- Running the app with minimal system resources
Correct answer: Requesting only the permissions absolutely necessary for the app to function
The principle of least privilege means declaring only the minimum required permissions to reduce the attack surface and potential harm if the app is compromised.
Question 18: How do you perform a database migration in Room when the schema changes?
- By providing a Migration object with SQL migration scripts (Correct answer)
- Room handles migrations automatically
- By deleting and recreating the database
- By using @SchemaVersion annotation
Correct answer: By providing a Migration object with SQL migration scripts
Room requires you to provide a Migration object containing the SQL statements needed to transform the old schema to the new one.
Question 19: What does APK size optimization technique 'code shrinking' do via R8 or ProGuard?
- Splits the APK by screen density
- Reduces the number of Activities in the manifest
- Compresses image assets into WebP format
- Removes unused classes, fields, methods, and attributes from the compiled output (Correct answer)
Correct answer: Removes unused classes, fields, methods, and attributes from the compiled output
Code shrinking with R8/ProGuard analyzes the code graph and removes unused classes, fields, methods, and attributes, producing a smaller, faster APK.
Question 20: Which Android API checks whether a runtime permission has been granted?
- PackageManager.hasPermission()
- Permission.isGranted()
- ContextCompat.checkSelfPermission() (Correct answer)
- ActivityCompat.requestPermissions()
Correct answer: ContextCompat.checkSelfPermission()
ContextCompat.checkSelfPermission() returns PERMISSION_GRANTED or PERMISSION_DENIED to indicate whether the app has a specific runtime permission.
Question 21: What is the main benefit of using ConstraintLayout over nested LinearLayouts or RelativeLayouts?
- It removes the need for ViewHolders in RecyclerView
- It flattens the view hierarchy, reducing measure/layout passes (Correct answer)
- It supports hardware acceleration by default
- It automatically caches view positions
Correct answer: It flattens the view hierarchy, reducing measure/layout passes
ConstraintLayout expresses complex layouts in a single flat hierarchy, avoiding nested layouts that require multiple measure/layout passes and hurt rendering performance.
Question 22: What is the difference between unit tests and instrumentation tests in Android?
- Unit tests run on JVM; instrumentation tests run on an Android device or emulator (Correct answer)
- Unit tests are slower than instrumentation tests
- There is no difference
- Instrumentation tests don't require an emulator
Correct answer: Unit tests run on JVM; instrumentation tests run on an Android device or emulator
Unit tests run locally on the JVM and are fast, while instrumentation tests run on an Android device/emulator and can access the Android framework.
Question 23: What is the recommended way to load large bitmaps efficiently to avoid OutOfMemoryError in Android?
- Increase the app's heap size in the manifest
- Use BitmapFactory.Options to subsample the bitmap before decoding (Correct answer)
- Load the full bitmap and then scale it in an ImageView
- Convert all images to PNG format
Correct answer: Use BitmapFactory.Options to subsample the bitmap before decoding
Setting BitmapFactory.Options.inSampleSize decodes a subsampled version of the bitmap, reducing memory usage significantly before the bitmap is loaded into memory.
Question 24: What does the term REST stand for in the context of Android networking?
- Resource Exchange Standard Transfer
- Remote Execution State Transfer
- Reliable Endpoint Service Transfer
- Representational State Transfer (Correct answer)
Correct answer: Representational State Transfer
REST (Representational State Transfer) is an architectural style for building scalable web services using standard HTTP methods.
Question 25: What return type should a Room DAO method use to observe database changes reactively?
- Observable<T>
- LiveData<T>
- Both A and B (Correct answer)
- Flow<T>
Correct answer: Both A and B
Room supports both Flow<T> and LiveData<T> as return types for DAO queries, enabling reactive observation of database changes.
Question 26: Which Android Jetpack library provides an abstraction layer over SQLite for local data persistence?
- Room (Correct answer)
- LiveData
- SQLiteOpenHelper
- DataStore
Correct answer: Room
Room is a persistence library that provides compile-time verification of SQL queries and abstracts SQLite database access.
Question 27: What is SQL injection and how does Room protect against it?
- Room validates input length
- Room uses stored procedures
- Room encrypts all queries
- Room uses parameterized queries with placeholders that prevent user input from being interpreted as SQL (Correct answer)
Correct answer: Room uses parameterized queries with placeholders that prevent user input from being interpreted as SQL
Room's @Query annotation uses parameterized queries where user input is bound as data, not parsed as SQL, preventing injection attacks.
Question 28: What annotation marks a class as a Room database entity?
- @Table
- @Model
- @DatabaseObject
- @Entity (Correct answer)
Correct answer: @Entity
The @Entity annotation marks a Kotlin or Java class as a Room database table, with each field mapping to a column.
Question 29: Which approach minimizes object allocation in performance-critical Android code to reduce garbage collection pauses?
- Increase the app's maximum heap size
- Always use ArrayList over arrays
- Disable hardware acceleration for frequently-redrawn views
- Use StringBuilder instead of String concatenation in tight loops (Correct answer)
Correct answer: Use StringBuilder instead of String concatenation in tight loops
String concatenation with + in a loop creates many intermediate String objects; StringBuilder reuses its internal buffer, reducing GC pressure in tight loops.
Question 30: What does the @Before annotation do in JUnit?
- Indicates a precondition assertion
- Marks a method to run before each test method in the class (Correct answer)
- Marks a setup method that runs once
- Runs code before the test class loads
Correct answer: Marks a method to run before each test method in the class
@Before marks a method that JUnit executes before each @Test method, commonly used for test setup like initializing objects.
Question 31: What is the purpose of the NetworkSecurityConfig in Android?
- To manage VPN connections
- To define trusted Certificate Authorities and network security policies (Correct answer)
- To configure WiFi settings
- To set firewall rules
Correct answer: To define trusted Certificate Authorities and network security policies
NetworkSecurityConfig allows you to customize network security settings like trusted CAs, cleartext traffic, and certificate pinning via XML.
Question 32: Which SQL clause is used in a Room @Query to filter results?
- CONDITION
- HAVING
- FILTER
- WHERE (Correct answer)
Correct answer: WHERE
The WHERE clause in Room SQL queries filters rows that meet a specified condition, just as in standard SQL.
Question 33: What does the term 'memory leak' mean in Android development?
- The GPU runs out of texture memory
- An object is kept in memory longer than its intended lifecycle (Correct answer)
- The app writes too much data to disk
- The app uses too much network bandwidth
Correct answer: An object is kept in memory longer than its intended lifecycle
A memory leak occurs when references prevent the garbage collector from reclaiming objects whose lifecycle has ended, such as an Activity referenced by a static field.
Question 34: When using DiffUtil with RecyclerView, what is the main performance advantage over calling notifyDataSetChanged()?
- It calculates the minimal set of changes and animates only affected items (Correct answer)
- It prevents the RecyclerView from scrolling during updates
- It batches all updates into a single transaction
- It moves list operations to a background thread automatically
Correct answer: It calculates the minimal set of changes and animates only affected items
DiffUtil computes the difference between two lists and dispatches granular add/remove/move/change events, avoiding the full rebind that notifyDataSetChanged() triggers.
Question 35: Which Android feature allows deferring the inflation of part of a layout until it is actually needed, improving initial load time?
- ViewStub (Correct answer)
- MotionLayout
- Data Binding
- ConstraintLayout chains
Correct answer: ViewStub
ViewStub is a lightweight, invisible View that is replaced by the inflated layout only when explicitly made visible or inflated, reducing startup inflation cost.
Question 36: Which RecyclerView component is responsible for measuring and positioning item views?
- RecycledViewPool
- LayoutManager (Correct answer)
- ItemDecoration
- ViewHolder
Correct answer: LayoutManager
The LayoutManager in RecyclerView handles the layout strategy for its child views, such as linear, grid, or staggered arrangements.
Question 37: In Android, which of the following are the screen sizes?
- Small
- Large
- All of the above (Correct answer)
- Extralarge
Correct answer: All of the above
Android supports a variety of screen sizes to accommodate the diverse range of devices available in the market. These categories include small, normal, large, and extra-large. Developers design their layouts to be flexible and responsive, ensuring a consistent and optimal user experience across all these different screen dimensions.
Question 38: Which HTTP method is used to update a resource partially in REST APIs?
- PATCH (Correct answer)
- POST
- PUT
- UPDATE
Correct answer: PATCH
PATCH is used to apply partial modifications to a resource, while PUT replaces the entire resource.
Question 39: What is the purpose of the RecyclerView.RecycledViewPool in Android?
- To share recycled ViewHolders across multiple RecyclerViews (Correct answer)
- To limit the number of views that can be inflated
- To persist scroll position across configuration changes
- To cache network responses for list items
Correct answer: To share recycled ViewHolders across multiple RecyclerViews
RecycledViewPool allows multiple RecyclerViews to share a pool of recycled ViewHolders, reducing view inflation overhead when displaying similar list content.
Question 40: You'll need an AVD to make an emulator. What exactly does it mean?
- Android Virtual Display
- Active Virtual Device
- Application Virtual Display
- Android Virtual Device (Correct answer)
Correct answer: Android Virtual Device
AVD stands for Android Virtual Device. It is a configuration that defines the characteristics of an Android phone, tablet, or other device that you want to simulate in the Android Emulator. An AVD specifies the Android version, hardware features, and screen size for the virtual device, allowing developers to test their apps on various configurations.
Question 41: Which library is used for efficient image loading from URLs in Android apps?
- Glide
- All of the above (Correct answer)
- Picasso
- Coil
Correct answer: All of the above
Glide, Picasso, and Coil are all popular Android image loading libraries that handle downloading, caching, and displaying images from URLs.
Question 42: Which component in Material Design is used to display brief, non-disruptive messages at the bottom of the screen?
- AlertDialog
- Dialog
- Toast
- Snackbar (Correct answer)
Correct answer: Snackbar
Snackbar provides brief feedback about an operation at the bottom of the screen and can include an optional action.
Question 43: What permission is required for an Android app to access the internet?
- android.permission.ONLINE
- android.permission.INTERNET (Correct answer)
- android.permission.NETWORK
- android.permission.ACCESS_NETWORK
Correct answer: android.permission.INTERNET
The android.permission.INTERNET permission must be declared in AndroidManifest.xml for an app to make network requests.
Question 44: What is the purpose of the EncryptedSharedPreferences in Android?
- To encrypt network traffic
- To store encrypted database credentials
- To share encrypted files between apps
- To encrypt both keys and values stored in SharedPreferences (Correct answer)
Correct answer: To encrypt both keys and values stored in SharedPreferences
EncryptedSharedPreferences from Jetpack Security encrypts both the keys and values using AES-256, protecting sensitive preference data at rest.
Question 45: What does WAL mode stand for in SQLite?
- Web API Layer
- Write and Load
- Write Access Lock
- Write-Ahead Logging (Correct answer)
Correct answer: Write-Ahead Logging
WAL (Write-Ahead Logging) mode in SQLite allows concurrent reads and writes, improving performance in multi-threaded apps.
Android Certified Application Developer (AND-X01)
The AndroidATC AND-X01 certification validates skills in Android application development including core Android APIs, UI design, data storage, security, performance optimization, background processing, and testing.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds