📇 記憶閃卡特訓

🎯 模擬測驗題庫

Question 1: Android Architecture & Root Responsibilities

Context: The Android Architecture is a multi-layered software stack. Developers often interact with the Application Framework, but the system relies heavily on lower layers to function properly.

Q1.

Question: Which of the following statements strictly describes the fundamental responsibility of the Linux Kernel layer within the Android Architecture stack, deliberately distinguishing it from the Android Runtime (ART) and the Hardware Abstraction Layer (HAL)?

💡 點評解答: 正確答案是 C。

Question 1: 答案是 C (Linux Kernel)

  • ELI5 剖析:Linux Kernel 是 Android 最底層的「大總管」,專門負責跟硬體打交道(記憶體、電源、相機驅動程式)。
  • 陷阱破解:選項 A 是硬體抽象層 (HAL) 的工作;選項 B 是 Android Runtime (ART) 的工作;選項 D 則是 Application Framework (應用程式框架) 的工作。

Question 2: Advanced Lifecycle Transition (Transparent UI)

Context: Activity lifecycle transitions require precise understanding, especially when dealing with overlapping UI components.

Q1.

Question:Activity A is currently running in the foreground. A user clicks a button that launches Activity B. Activity B is explicitly defined in the AndroidManifest.xml with the Theme.AppCompat.Dialog (a transparent/floating theme). Which of the following sequences accurately represents the execution order of the lifecycle callbacks during this specific transition?

💡 點評解答: 正確答案是 B。

Question 2: 答案是 B (A pause, B create/start/resume)

  • ELI5 剖析:這是 Lifecycle 最毒的陷阱!因為 Activity B 是一個 Dialog (透明/半遮蔽),所以底下的 Activity A 「還看得到」。只要還看得到,A 就只會進入 onPause()絕對不會進入 onStop()(完全看不見才會 Stop)。
  • 陷阱破解:選項 A 和 D 都讓 Activity A 進入了 onStop(),這是最常見的考生直覺錯誤。

Question 3: Device Fragmentation & Density Math

Context: To overcome Android device fragmentation, developers use dp (Density-independent Pixels) instead of px (Physical Pixels) to ensure consistent UI sizing across different screens. The baseline density in Android is defined as mdpi (160 dpi).

Q1.

Question: If a button is strictly defined in XML as android:layout_width="100dp", how will the Android system calculate its actual physical pixel dimension when rendered on an xxhdpi (Extra-Extra-High Density, approx. 480 dpi) screen?

💡 點評解答: 正確答案是 D。

Question 3: 答案是 D (300 pixels)

  • ELI5 剖析:這是必考的排版數學題。基準點 mdpi 是 160 dpi。公式是:px = dp * (螢幕 dpi / 160)
  • 陷阱破解:手機是 xxhdpi (480 dpi),剛好是 160 的 3 倍。所以你在 XML 寫 100dp,系統會自動幫你放大 3 倍,變成 300px 來顯示,這樣按鈕在超高解析度手機上才不會縮水變成一個小點。

Chapter 1: Android Architecture & Components (Advanced)

沒錯,系統具備專屬的互動測驗室功能。既然你想要挑戰最高難度的 A+ (Distinction) 等級,我將直接為你更新這個名為「Chapter 1: Android Architecture & Components (Advanced)」的互動題庫。這些題目專注於第一章的核心考點(架構分層、虛擬機機制、四大元件、安全性沙盒等),並且佈滿了考驗底層邏輯的陷阱選項。

Q1.

Which of the following strictly falls under the direct responsibility of the Linux Kernel layer within the Android software stack?

💡 點評解答: 正確答案是 D。

The Linux Kernel sits at the very bottom, handling core system services like memory,
processes, and drivers for camera, keypad, etc.

Q2.

Android applications are compiled into a specific format to run on the Android Runtime (ART). What is this compiled format?

It is an optimized format that was originally named after the virtual machine created by Dan Bornstein.
💡 點評解答: 正確答案是 B。

Android build tools convert Java/Kotlin bytecode (.class) into highly optimized .dex files
designed for mobile resource constraints.

Q3.

If you are developing a music streaming application, which fundamental Android component must you implement to ensure music continues to play even when the user navigates away from your app?

💡 點評解答: 正確答案是 D。

A Service tells the Android OS that the application is performing ongoing work, significantly
reducing the chance of the process being killed.

Q4.

Your application relies on a local SQLite database. You need to allow a completely separate, third-party application to securely query and modify specific tables within your database. Which component is strictly required?

Think of this component as a secure bridge or API specifically built for data sharing.
💡 點評解答: 正確答案是 A。

Content Providers act as a secure, standardized interface for sharing data between completely different application processes.

Q5.

Which component acts as a dormant listener, remaining inactive until the Android system announces a specific system-wide event, such as 'Low Battery' or 'Screen Turned Off'?

It receives 'announcements' broadcasted by the OS.
💡 點評解答: 正確答案是 A。

Broadcast Receivers are designed exactly for this: they sleep until the OS fires an Intent
broadcasting a specific system event.

Q6.

When an Android developer uses classes like ActivityManager, LocationManager, or NotificationManager in their code, which layer of the architecture are they directly interacting with?

This is the primary layer developers write code against.
💡 點評解答: 正確答案是 C。

The Application Framework provides the high-level Java/Kotlin APIs (all the 'Managers') that developers use to build apps.

Q7.

You create an Intent specifying ACTION_VIEW and a webpage URL. How does the Android system determine which application should ultimately handle this Implicit Intent?

The system needs a registry of what each app is capable of doing.
💡 點評解答: 正確答案是 A。

For Implicit Intents, the system checks the AndroidManifest.xml of all apps to find an Intent
Filter that matches the Action and Data.

Q8.

To enforce robust security and application isolation (Sandboxing), what does the Android Linux Kernel assign to every newly installed application by default?

Android treats every application as if it were a different 'person' logging into a Linux computer.
💡 點評解答: 正確答案是 D。

Android leverages the Linux user-based protection model. Every app gets a unique UID,
ensuring it runs in its own isolated process.

Q9.

第 9 題

The Application Framework requests access to the device camera. The Linux Kernel holds the actual camera driver. What architectural layer sits between them to provide standard interfaces?

It 'abstracts' the specific hardware details so the framework can use a unified API.
💡 點評解答: 正確答案是 A。

HAL provides standard interfaces that expose device hardware capabilities to the higher-level
Java API framework.

Q10.

第 10 題

After writing Java/Kotlin code and defining XML layouts, the build system packages everything into an APK. Which of the following accurately describes the compiled code contents inside a standard APK?

Think about the specific format optimized for the Android Runtime.
💡 點評解答: 正確答案是 A。

An APK contains the optimized .dex files that the Android Runtime actually executes, along
with resources and the Manifest.

Q11.

第 11 題

If you want your application's MainActivity to be launched directly from the device's home screen launcher, which specific file must explicitly contain the Intent Filter configuration?

This file serves as the definitive blueprint presented to the Android operating system upon installation.
💡 點評解答: 正確答案是 B。

The Manifest is the blueprint of the app. It must contain an Intent Filter with ACTION_MAIN
and CATEGORY_LAUNCHER for the home screen to see it.

Q12.

第 12 題

According to the fundamental Android Activity Lifecycle architecture, the entire lifetime of an activity strictly happens between which two callback methods?

Consider the absolute birth and the absolute death of the component.
💡 點評解答: 正確答案是 B。

The absolute creation (birth) starts at onCreate(), and the final termination (death) occurs at onDestroy().

Q13.

第 13 題

The Android architecture includes a layer of C/C++ libraries (such as SQLite, OpenGL ES, and FreeType). What is the primary architectural purpose of this specific layer?

These are heavy-duty engines optimized for performance.
💡 點評解答: 正確答案是 B。

Native libraries like OpenGL handle heavy 2D/3D rendering, and SQLite handles optimized database operations.

Q14.

第 14 題

In the Android OS boot process, the system uses a special daemon process that preloads core libraries and acts as a template for newly launched app processes. What is the name of this mechanism?

The name comes from biology, representing an initial cell from which all others divide.
💡 點評解答: 正確答案是 B。

Zygote is a foundational process that preloads classes and resources, enabling rapid 'forking' to launch new apps extremely quickly.

Q15.

第 15 題

An Intent is created using the syntax: 'new Intent(CurrentActivity.this, TargetActivity.class)'. What is the defining characteristic of this Explicit Intent compared to an Implicit one?

Look at the arguments passed into the Intent constructor.
💡 點評解答: 正確答案是 D。

An Explicit Intent specifies the exact ComponentName (the target class), leaving no ambiguity for the OS.