Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
Question 1 of 60 · Introduction to AI in mobile apps · Easy
What is a primary benefit of integrating AI into mobile applications?
Not quite. Try another option.
Answer: To enhance the user experience with personalized features
AI enables features like personalized recommendations, intelligent replies, and content discovery, which makes the app more engaging and useful for the user.
Question 2 of 60 · Introduction to AI in mobile apps · Easy
Which of the following is a common example of AI being used in a mobile app?
Not quite. Try another option.
Answer: An e-commerce app that suggests products based on your viewing history
Recommendation engines are a classic application of AI that analyze user behavior to suggest relevant items, thereby personalizing the shopping experience.
Question 3 of 60 · Role of AI assistants in Android · Easy
What is the primary AI assistant developed by Google for the Android platform?
Not quite. Try another option.
Answer: Google Assistant
Google Assistant is Google's native AI-powered virtual assistant, deeply integrated into the Android operating system and other Google products.
Question 4 of 60 · Role of AI assistants in Android · Easy
Besides answering questions, what is a common function of an AI assistant on an Android device?
Not quite. Try another option.
Answer: Controlling device settings like Wi-Fi or Bluetooth
AI assistants can perform actions on the device itself, such as turning settings on/off, setting alarms, or opening apps, based on voice commands.
Question 5 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Easy
Which company is the creator of the ChatGPT language model?
Not quite. Try another option.
Answer: OpenAI
ChatGPT is a family of large language models developed by the artificial intelligence research and deployment company, OpenAI.
Question 6 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Easy
Gemini is a family of powerful, multimodal AI models developed by which company?
Not quite. Try another option.
Answer: Google
Gemini is Google's flagship collection of generative AI models, designed to handle various data types including text, images, and audio.
Question 7 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Easy
What does it mean for an AI model like Gemini to be "multimodal"?
Not quite. Try another option.
Answer: It can understand and process multiple types of data (e.g., text, images, audio)
A multimodal AI can process and reason about various data formats, or modalities. For instance, it can analyze an image and answer a text-based question about it.
Question 8 of 60 · Basics of AI APIs REST APIs and API keys · Easy
What does the acronym API stand for?
Not quite. Try another option.
Answer: Application Programming Interface
An API is a set of rules and tools that allows one software application to communicate with another.
Question 9 of 60 · Basics of AI APIs REST APIs and API keys · Easy
What is the primary purpose of an API key when using a service like the Google Gemini API?
Not quite. Try another option.
Answer: To authenticate your application's requests to the service
An API key is a unique secret token used to identify and authorize your app, ensuring that only approved applications can access the API and allowing the service to track usage.
Question 10 of 60 · Basics of AI APIs REST APIs and API keys · Easy
REST APIs most commonly use which web protocol for communication?
Not quite. Try another option.
Answer: HTTP/HTTPS
REST (Representational State Transfer) is an architectural style that leverages the standard methods of the HTTP/HTTPS protocol, like GET and POST, for client-server communication.
Question 11 of 60 · Integrating Google Gemini API in Android · Easy
What is the most critical prerequisite for an Android developer before they can make calls to the Google Gemini API?
Not quite. Try another option.
Answer: Obtaining an API key from Google
Access to the Gemini API is protected. You must first generate an API key through a Google service (like Google AI Studio) to authenticate your app's requests.
Question 12 of 60 · Integrating Google Gemini API in Android · Easy
To simplify the process of using Google's generative AI models in an Android app, what should a developer use?
Not quite. Try another option.
Answer: The official Google AI for Android SDK
Google provides a specific Software Development Kit (SDK) to make integration with the Gemini API much easier by handling complex tasks like request formatting and authentication.
Question 13 of 60 · Generating AI text responses · Easy
When interacting with a generative AI model, what is the term for the input text or question you provide to it?
Not quite. Try another option.
Answer: A prompt
A prompt is the initial instruction or query given to an AI model to guide it in generating the desired output.
Question 14 of 60 · Generating AI text responses · Easy
After sending a prompt to the Gemini API, what does your application receive back upon a successful request?
Not quite. Try another option.
Answer: A generated text response from the AI model
The fundamental purpose of calling a generative AI API is to receive a newly created response (text, image, etc.) from the model based on your input prompt.
Question 15 of 60 · Handling user input and AI output · Easy
Which standard Android UI widget is most suitable for allowing a user to type in a multi-line prompt for an AI?
Not quite. Try another option.
Answer: EditText
An EditText is the primary component for user-editable text fields in Android, making it the correct choice for capturing user input like a prompt.
Question 16 of 60 · Handling user input and AI output · Easy
To display the text response received from an AI API to the user, which non-editable UI widget is the best choice?
Not quite. Try another option.
Answer: TextView
A TextView is designed to display static or dynamic text that the user cannot edit, which is perfect for showing the AI's generated response.
Question 17 of 60 · Basic error handling and API usage limits · Easy
In the context of APIs, what is a 'rate limit'?
Not quite. Try another option.
Answer: A limit on the number of requests an app can make in a given time period
Service providers set rate limits (e.g., 60 requests per minute) to ensure service stability and prevent abuse by any single user or application.
Question 18 of 60 · Basic error handling and API usage limits · Easy
If your app makes an API request but has no internet connection, what is the most likely outcome?
Not quite. Try another option.
Answer: A network error will occur and the request will fail
API calls require a network connection to reach the remote server. Without one, the request cannot be sent, leading to a network-related error or exception in the app.
Question 19 of 60 · Basic error handling and API usage limits · Easy
What kind of response should your app expect if it uses an incorrect or expired API key?
Not quite. Try another option.
Answer: An authentication error (e.g., HTTP 401 Unauthorized or 403 Forbidden)
An invalid API key will cause the server to reject the request because the app cannot be properly authenticated. This is communicated via an authentication error status code.
Question 20 of 60 · Basics of AI APIs REST APIs and API keys · Easy
In the client-server architecture used by AI APIs, what role does your Android app play?
Not quite. Try another option.
Answer: The Client
The Android application is the 'client' that initiates requests for information or services from the remote 'server,' which hosts the AI model and processes those requests.
Question 21 of 60 · Introduction to AI in mobile apps · Medium
An e-commerce app wants to implement a feature to help users find products by describing them in natural language (e.g., "show me red running shoes for trails"). Which AI capability is most directly applicable to this task?
Not quite. Try another option.
Answer: Natural Language Understanding (NLU)
NLU is the branch of AI focused on interpreting and understanding human language, which is essential for processing a user's descriptive search query to extract intent and entities (like 'running shoes', 'red', and 'trails').
Question 22 of 60 · Introduction to AI in mobile apps · Medium
What is a key advantage of using a cloud-based AI model (like the Gemini API) over an on-device model (like Gemini Nano) for a complex mobile app feature?
Not quite. Try another option.
Answer: It can leverage much larger, more powerful models without impacting the device's local performance.
Cloud-based AI models run on powerful servers, allowing them to be much larger and more capable than models that can fit on a mobile device, all without consuming the user's local CPU, RAM, or battery.
Question 23 of 60 · Role of AI assistants in Android · Medium
A developer wants to allow users to say, "Hey Google, start a run in FitApp." Which Android framework is specifically designed to enable this kind of integration with the Google Assistant?
Not quite. Try another option.
Answer: App Actions
App Actions allow you to extend your app's functionality to the Google Assistant, enabling users to trigger specific features and intents within your app using voice commands.
Question 24 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Medium
What is the primary architectural and use-case difference between a model like Gemini Pro and a model like Gemini Nano?
Not quite. Try another option.
Answer: Gemini Pro is a large, server-side model for complex tasks, while Gemini Nano is a smaller model designed to run efficiently on-device.
Google's model family is designed for different scales. Gemini Pro is a powerful, versatile model that runs in the cloud, whereas Gemini Nano is a highly efficient model optimized for on-device tasks on Android where latency and offline capability are important.
Question 25 of 60 · Basics of AI APIs REST APIs and API keys · Medium
When making a REST API call to a service like the Gemini API, why is it considered more secure to send the API key in an HTTP header (e.g., x-goog-api-key) rather than as a URL query parameter?
Not quite. Try another option.
Answer: URLs, including their query parameters, are often logged in server logs, browser history, and network proxies, exposing the key.
Placing sensitive information like an API key in the URL makes it vulnerable to exposure through server logs, browser history, and network intermediaries. Headers are part of the request that are less likely to be logged, making them a more secure location for authentication tokens.
Question 26 of 60 · Integrating Google Gemini API in Android · Medium
When using the Google AI SDK for Android with Kotlin, what is the main purpose of the GenerativeModel class?
Not quite. Try another option.
Answer: It is the primary entry point for interacting with the Gemini model to generate content and start chats.
The GenerativeModel class is the core component of the SDK. You instantiate it with your model name and configuration, and then use its methods like generateContent or startChat to communicate with the Gemini API.
Question 27 of 60 · Generating AI text responses · Medium
In an Android app using Kotlin Coroutines to call the Gemini API, which CoroutineScope and Dispatcher would be most appropriate for launching the network request to prevent blocking the main thread?
Not quite. Try another option.
Answer: lifecycleScope.launch(Dispatchers.IO)
Network operations are I/O-bound and should never run on the main thread. Dispatchers.IO is specifically optimized for this type of work. Using lifecycleScope ensures the coroutine is automatically cancelled if the Activity or Fragment is destroyed, preventing memory leaks.
Question 28 of 60 · Basic error handling and API usage limits · Medium
Your app receives an HTTP 429 Too Many Requests error from the Gemini API. What is the most effective short-term strategy to handle this error and recover gracefully?
Not quite. Try another option.
Answer: Implement an exponential backoff strategy, waiting for a progressively longer time before retrying.
A 429 error indicates you've exceeded your rate limit. An exponential backoff strategy (e.g., waiting 1s, then 2s, then 4s) is the standard method to handle this, as it reduces the load on the server and increases the chance of a successful subsequent request.
Question 29 of 60 · Handling user input and AI output · Medium
You are displaying a response from the Gemini API that is being streamed. To improve the user experience, which approach is best for updating the TextView?
Not quite. Try another option.
Answer: Append chunks of text to the TextView as they are received from the stream, creating a "typing" effect.
Streaming allows the model to send back the response in pieces. Updating the UI as these chunks arrive provides immediate feedback to the user and makes the app feel more responsive and dynamic, mimicking a real-time conversation.
Question 30 of 60 · Basics of AI APIs REST APIs and API keys · Medium
When making a direct REST API call to a text-generation model like Gemini, the user's prompt and other parameters like temperature are typically sent in which part of the HTTP request?
Not quite. Try another option.
Answer: In the request body, formatted as a JSON object.
Complex and potentially long data, such as a user's prompt, model parameters, and conversation history, is structured and sent in the request body. JSON is the most common format for this data payload in modern REST APIs.
Question 31 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Medium
What does it mean for a generative AI model like Gemini to be "multimodal"?
Not quite. Try another option.
Answer: It can process and understand information from multiple types of data, such as text, images, and audio, within a single prompt.
Multimodality is the ability of an AI model to handle and reason about different data formats (modalities) simultaneously. For example, you can give Gemini an image and ask a question about it using text in the same request.
Question 32 of 60 · Integrating Google Gemini API in Android · Medium
Consider the following Kotlin code snippet for initializing the Gemini model in an Android app. What is the most significant security risk with this direct approach?
Answer: Hardcoding the API key directly in the source code makes it vulnerable to being extracted from the compiled APK.
Hardcoding secrets like API keys in your client-side code is a major security flaw. Anyone who decompiles your APK can find and misuse your key. Keys should be stored securely, for example, in local.properties and accessed via BuildConfig, and further protected with server-side proxies or API key restrictions.
Question 33 of 60 · Generating AI text responses · Medium
When building a chatbot feature using the Gemini Android SDK, what is the primary benefit of using generativeModel.startChat() over making repeated calls to generativeModel.generateContent()?
Not quite. Try another option.
Answer: It creates a Chat object that automatically maintains the conversation history, providing context for follow-up messages.
Unlike stateless generateContent calls, startChat() initializes a stateful chat session. The returned Chat object keeps track of the back-and-forth, so when you send a new message, the previous turns are sent along as context, enabling a coherent conversation.
Question 34 of 60 · Basic error handling and API usage limits · Medium
To prevent unauthorized use of your Gemini API key in other applications, what is a recommended security practice available in the Google Cloud Console?
Not quite. Try another option.
Answer: Applying an API key restriction to only allow requests from your app's specific package name and SHA-1 certificate fingerprint.
API providers like Google allow you to add application restrictions. By locking the key to your app's unique signature, you ensure that even if the key is extracted, it cannot be used from any other application, significantly mitigating misuse.
Question 35 of 60 · Handling user input and AI output · Medium
Your app has an EditText for user input and a Button to send a prompt to the Gemini API. What is a recommended UI/UX practice to implement immediately after the user taps the send button?
Not quite. Try another option.
Answer: Disable the Button and EditText and show a loading indicator to prevent multiple submissions while waiting for a response.
Disabling input controls and showing a visual indicator of activity (like a progress bar) provides clear feedback, prevents the user from sending duplicate requests, and manages the application state properly while waiting for an asynchronous operation to complete.
Question 36 of 60 · Introduction to AI in mobile apps · Medium
Which of the following is a clear example of Generative AI being used in a mobile application?
Not quite. Try another option.
Answer: An editing app that creates a novel image from the text prompt "a photo of a cat wearing a spacesuit on Mars".
Generative AI is focused on creating new, original content (text, images, code, etc.) that did not exist before. Face detection, word prediction, and activity classification are all forms of predictive or classificatory AI, not generative AI.
Question 37 of 60 · Role of AI assistants in Android · Medium
How do AI assistants like Google Assistant fundamentally enhance user interaction on Android compared to a traditional app-only interface?
Not quite. Try another option.
Answer: By allowing users to interact with app features hands-free and from a system-level interface, without opening the app manually.
The core value of an AI assistant is providing a conversational, system-wide interface. It allows users to perform actions without needing to manually find and navigate through a specific app, often using voice, which is crucial for accessibility and convenience.
Question 38 of 60 · Integrating Google Gemini API in Android · Medium
When adding the Google AI Client SDK for Android to your project using Gradle, in which file do you typically declare the implementation("com.google.ai.client.generativeai:generativeai:...") dependency?
Not quite. Try another option.
Answer: In the module-level build.gradle (or build.gradle.kts) file's dependencies block.
External libraries and SDKs for a specific Android application module (like the 'app' module) are declared in that module's build.gradle or build.gradle.kts file, using the implementation configuration in the dependencies block.
Question 39 of 60 · Generating AI text responses · Medium
In the context of the Gemini API's generationConfig, what does the "temperature" parameter primarily control?
Not quite. Try another option.
Answer: The degree of randomness in the output; a lower value is more deterministic, while a higher value is more creative.
Temperature is a key parameter for controlling the output of LLMs. A low temperature (e.g., 0.2) makes the model choose more likely, predictable words, resulting in focused responses. A high temperature (e.g., 0.9) increases randomness, leading to more diverse or creative outputs.
Question 40 of 60 · Basic error handling and API usage limits · Medium
When you make a request to the Gemini API and receive a response where response.text is null but no network or authentication exception was thrown, what is a likely cause related to the API's configuration?
Not quite. Try another option.
Answer: The model's response was blocked due to a safety policy violation (e.g., generating harmful content).
The Gemini API has built-in safety filters. If a prompt or the model's generated response violates these filters, the API may block the response. This often manifests as an empty or null content field rather than a server error, indicating the content was successfully filtered.
Question 41 of 60 · Introduction to AI in mobile apps · Hard
An Android application for real-time video analysis needs to apply a complex, computationally intensive object detection model. The app must function with minimal latency even with intermittent network connectivity. What is the most optimal AI model deployment strategy?
Not quite. Try another option.
Answer: Implement a hybrid approach using a quantized on-device model (e.g., TensorFlow Lite) for initial, low-latency detection and offloading complex analysis to a cloud API when a stable connection is available.
This hybrid approach balances latency, offline capability, and computational power. The quantized on-device model provides immediate, real-time feedback, while the cloud API can perform more nuanced, heavy analysis when connectivity permits, offering the best of both worlds for this use case.
Question 42 of 60 · Basic error handling and API usage limits · Hard
Your Android app, using the Gemini API, suddenly starts receiving HTTP 429 Too Many Requests errors. You've implemented a simple retry mechanism, but it's not resolving the issue. What is the most robust strategy to handle this specific error and ensure service resilience?
Not quite. Try another option.
Answer: Implement an exponential backoff strategy with jitter, starting with a short delay and progressively increasing it for subsequent retries, while respecting the Retry-After header if present.
An exponential backoff strategy with jitter is the industry-standard approach for handling rate limiting. It prevents a "thundering herd" problem where all clients retry simultaneously, worsening the server load. Adding jitter (randomness) further staggers the retries. Respecting the Retry-After header is crucial for complying with the API's specific instructions.
Question 43 of 60 · Integrating Google Gemini API in Android · Hard
When building a conversational chat feature in an Android app using the Google Gemini SDK, you need to maintain the context of the entire conversation. Which Gemini SDK component is specifically designed for this purpose, and how does it manage the history?
Not quite. Try another option.
Answer: The Chat object, initiated via model.startChat(), which internally manages the conversation history and automatically includes it in subsequent sendMessage() calls.
The Chat object in the Gemini SDK is purpose-built for multi-turn conversations. It abstracts away the complexity of managing history by maintaining the state internally. When you call sendMessage() on a Chat instance, the SDK automatically appends the new message to the history and sends the relevant context to the API.
Question 44 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Hard
You are designing an application that requires generating both creative text and analyzing the content of user-uploaded images in a single API call. Which model and API feature would be most suitable for this "multimodal" task?
Not quite. Try another option.
Answer: Google's Gemini Pro Vision model, which natively accepts both text and image data (e.g., a Bitmap) within a single prompt.
Gemini Pro Vision is explicitly designed for multimodal input. It can process prompts that combine different data types like text and images simultaneously in one request, making it the most direct and efficient solution for this requirement. The other options involve multiple, less integrated steps.
Question 45 of 60 · Handling user input and AI output · Hard
An AI model is designed to return a JSON object representing a user's flight booking intent. However, due to model "hallucinations" or variations in prompting, the response is sometimes a natural language sentence describing the JSON instead of the JSON itself. What is the most resilient parsing strategy on the Android client?
Not quite. Try another option.
Answer: Attempt to parse the response as JSON first. If it fails, use a secondary prompt to ask the AI model to "reformat the previous response as a valid JSON object only".
This two-step approach is robust. It first tries the ideal, efficient path (direct parsing). If that fails, it uses the AI's own capabilities as a fallback mechanism to self-correct its output format. This is more reliable than brittle regex and provides a better user experience than a generic error.
Question 46 of 60 · Basics of AI APIs REST APIs and API keys · Hard
You need to store a Google Gemini API key in your Android project. Which of the following methods provides the strongest security against the key being extracted from a reverse-engineered APK?
Not quite. Try another option.
Answer: Proxying all API requests through a secure backend server that you control, where the API key is stored as an environment variable and never exposed to the client app.
No client-side storage method is completely secure. Even keys in BuildConfig or obfuscated code can be extracted. The only truly secure method is to never let the client app possess the key. A backend proxy service authenticates your app, makes the request to the AI provider using the secret key, and then forwards the response back to the app.
Question 47 of 60 · Generating AI text responses · Hard
You are using an LLM to generate code snippets. To get more deterministic and focused results, you want to reduce the randomness of the output. Which combination of API parameters should you adjust?
Not quite. Try another option.
Answer: Decrease temperature to a low value (e.g., 0.1) and decrease top_k to a small integer.
temperature controls randomness; a lower value makes the model choose higher-probability tokens, making the output more deterministic and focused. top_k sampling restricts the model's choices to the 'k' most likely next tokens. A small top_k further reduces randomness, complementing the low temperature for predictable tasks like code generation.
Question 48 of 60 · Role of AI assistants in Android · Hard
To enable Google Assistant to deep-link into a specific feature of your app and pass parameters (e.g., "Hey Google, order a pizza from MyPizzaApp"), your app needs to declare specific capabilities. What Android framework component is primarily used to achieve this integration?
Not quite. Try another option.
Answer: Defining App Actions using a shortcuts.xml resource file and linking them to capability definitions in your AndroidManifest.xml.
App Actions are the official framework for integrating with Google Assistant. You define built-in intents (like actions.intent.ORDER_MENU_ITEM) in a shortcuts.xml file, map them to your app's activities, and declare the capability to handle these intents. This allows the Assistant to understand user commands and fulfill them using your app's functionality.
Question 49 of 60 · Basic error handling and API usage limits · Hard
Your application makes streaming requests to the Gemini API to display text as it's generated. During a stream, the connection is lost. The Gemini SDK for Android throws an exception. What is the most appropriate recovery strategy to provide a seamless user experience?
Not quite. Try another option.
Answer: Store the partially received text, display it to the user with a "Resume" button, and upon clicking, send a new prompt asking the model to "continue from where you left off: [last few words of partial text]".
This approach preserves the work already done and provides the user with control. By re-prompting with the last known context, you can often get the model to seamlessly continue the generation, which is a much better experience than starting over or showing a hard error. The SDK does not automatically resume a broken stream.
Question 50 of 60 · Integrating Google Gemini API in Android · Hard
You are implementing a feature using the Gemini API that requires processing both an image and a text prompt. Using the generative-ai SDK for Android, how would you structure the input Content for the generateContent call?
Not quite. Try another option.
Answer: Use the content() builder function to construct a Content object containing two separate Parts: one created with image(bitmap) and another with text(prompt).
The Gemini SDK's content() builder is specifically designed for multimodal input. It allows you to create a single Content object composed of multiple Parts, where each part can hold a different data type (like an image or text). This is the correct and most efficient way to send multimodal prompts to models like Gemini Pro Vision.
Question 51 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Hard
When comparing the underlying architecture and training data cutoff of OpenAI's GPT-4 and Google's Gemini models (as of early 2024), what is a key differentiating factor that affects their ability to answer questions about very recent events?
Not quite. Try another option.
Answer: GPT-4 has a fixed knowledge cutoff date and cannot access real-time information, whereas some versions of Gemini are designed with integrations to Google Search for more up-to-date responses.
A significant architectural difference is that Google's ecosystem allows for easier and deeper integration of its models (like Gemini) with its real-time services (like Search). While base LLMs have training data cutoffs, certain product integrations (like in Google's Bard/Gemini app) can ground the model's responses with fresh, real-time information, a feature not natively available in the standard GPT-4 API in the same way.
Question 52 of 60 · Basics of AI APIs REST APIs and API keys · Hard
In the context of REST APIs for AI services, what is the primary purpose of an Idempotency-Key header, and in which scenario would it be most critical?
Not quite. Try another option.
Answer: To ensure that if a network error causes a request to be sent multiple times, the server only processes it once and returns the same result. This is critical for non-GET requests that modify state or incur costs.
Idempotency is crucial for operations that shouldn't be performed multiple times, such as submitting a payment or, in an AI context, initiating a costly generation job. By sending a unique Idempotency-Key, you tell the server, "If you've seen this key before, don't re-process the request; just send me the original result." This prevents duplicate actions and charges in case of network retries.
Question 53 of 60 · Handling user input and AI output · Hard
Your app uses an LLM to summarize long articles. You need to ensure the AI's output is always under 200 tokens to fit in a UI element. However, the model sometimes ignores the instruction "summarize in under 200 tokens". What is the most reliable technical constraint to enforce this limit?
Not quite. Try another option.
Answer: Set the max_output_tokens parameter in the API request to 200.
While prompt engineering is helpful, it's not a guarantee. Client-side truncation can abruptly cut off sentences, resulting in poor quality. Fine-tuning is overkill and expensive for this simple constraint. The max_output_tokens parameter is a direct, technical instruction to the API server to stop the generation process once the specified token limit is reached, making it the most reliable method for enforcing a hard length limit.
Question 54 of 60 · Introduction to AI in mobile apps · Hard
A mobile health app uses an on-device TensorFlow Lite model for real-time heart rate analysis from a camera feed. The developers want to personalize the model for each user over time without sending sensitive health data to the cloud. Which AI technique is best suited for this scenario?
Not quite. Try another option.
Answer: Federated Learning, where the model is trained locally on each device, and only the anonymous model updates (gradients or weights), not the raw data, are sent to a central server for aggregation.
Federated Learning is explicitly designed for privacy-preserving, decentralized machine learning. It allows the model to learn from user-specific data directly on their device. The sensitive raw data (the heart rate video) never leaves the phone. Only the mathematical updates to the model are shared, which are then used to improve the global model, benefiting all users while maintaining individual privacy.
Question 55 of 60 · Basic error handling and API usage limits · Hard
You are designing a feature that allows users to make up to 100 AI generation requests per day. What is the most scalable and reliable way to enforce this user-specific limit in a multi-device scenario (i.e., user is logged in on a phone and a tablet)?
Not quite. Try another option.
Answer: Implement a server-side counter associated with the user's account in your backend database. All client API calls must be proxied through this backend, which checks and updates the counter before forwarding the request to the AI provider.
Client-side solutions are unreliable for multi-device scenarios and can be easily tampered with. A user could simply clear app data or use two devices to circumvent the limit. The only robust solution is a centralized, server-side counter tied to the user's authenticated account. This ensures the limit is enforced consistently regardless of which device the user is on.
Question 56 of 60 · Integrating Google Gemini API in Android · Hard
Your app uses the Gemini SDK's streaming feature (generateContentStream) to display text. The design requires showing a "Stop Generating" button. How would you correctly implement the cancellation of an in-flight streaming request in a Kotlin Coroutine?
Kotlin
// Assume 'viewModelScope' is the CoroutineScope
var job: Job? = null
fun startGeneration() {
job = viewModelScope.launch {
generativeModel.generateContentStream(...)
.collect { ... }
}
}
Not quite. Try another option.
Answer: Call job?.cancel(), which leverages structured concurrency to propagate cancellation down to the underlying network call in the SDK.
The Google Gemini SDK for Android is built with Kotlin Coroutines in mind and supports cooperative cancellation. Calling job.cancel() on the coroutine that launched the stream will propagate the cancellation signal through the coroutine hierarchy. The SDK's generateContentStream function is designed to listen for this signal and will terminate the underlying network request, saving bandwidth and resources.
Question 57 of 60 · Generating AI text responses · Hard
You are building a chatbot that must avoid discussing certain sensitive topics. Which Gemini API feature is specifically designed to enforce content policies and prevent the model from generating harmful, unethical, or off-topic responses?
Not quite. Try another option.
Answer: Configuring the safety_settings parameter in the API request, adjusting the block thresholds for categories like HARM_CATEGORY_HARASSMENT or HARM_CATEGORY_DANGEROUS_CONTENT.
While prompt engineering and stop sequences can help, they are not foolproof. The safety_settings parameter is the dedicated, server-side mechanism provided by the API to enforce content safety. It allows you to define strict thresholds for various categories of harmful content, causing the API to block responses that violate these policies before they are even sent back to the client.
Question 58 of 60 · Role of AI assistants in Android · Hard
A productivity app wants to proactively suggest a "Create new project" action to the user via Google Assistant when the user receives an email about a new client. This requires the app's AI to operate based on contextual signals from other apps. What Android concept describes this type of proactive, on-device intelligence?
Not quite. Try another option.
Answer: Android's Private Compute Core, which enables features to process contextual data on-device in a privacy-preserving manner to power suggestions.
Android's Private Compute Core (PCC) is a secure, isolated environment on the device that allows apps and OS features (like Live Caption or Now Playing) to use on-device AI on ambient, contextual data without that data ever leaving the device. This is the underlying technology that would power proactive, privacy-safe suggestions from an assistant based on content from another app like Gmail. Using Accessibility APIs for this purpose would be a major privacy violation.
Question 59 of 60 · Overview of ChatGPT OpenAI and Gemini Google · Hard
In the context of large language models, what is the fundamental difference between how top_p (nucleus) sampling and top_k sampling control token generation?
Not quite. Try another option.
Answer: top_k selects a fixed number of the most probable tokens, while top_p selects a variable number of tokens whose cumulative probability exceeds a certain threshold p.
top_k is a simple truncation: consider only the k most likely next words. top_p is more dynamic: it creates the smallest possible set of most likely words whose cumulative probability is at least p. This means if one word is overwhelmingly likely, the set might contain only one word; if many words are equally likely, the set will be larger. This makes top_p generally more adaptive than the fixed-size top_k.
Question 60 of 60 · Handling user input and AI output · Hard
You're building an Android app where the Gemini API generates markdown-formatted text. To render this in a TextView, you need to convert the markdown to a Spanned object. What is a critical consideration for performance and user experience when handling a streamed markdown response?
Not quite. Try another option.
Answer: Append the incoming text chunks to a StringBuilder. Use a debouncing mechanism (e.g., a coroutine with debounce) to trigger markdown parsing and rendering on the TextView only after a short pause in the stream (e.g., 200ms), preventing UI freezes from excessive re-parsing on every character.
Re-parsing the entire markdown on every single incoming character is extremely inefficient and will cause the UI to stutter or freeze. Waiting until the end defeats the purpose of streaming. A debouncing strategy provides the best balance: it gives the user a near-real-time view of the text as it arrives but intelligently batches the computationally expensive markdown-to-Spanned conversion, ensuring a smooth UI thread and a responsive user experience.
That's unit 4
Answer a few questions and your score shows up here.
Nearly through. Did unit 4 of CSE227 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 4 of CSE227 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.