Marist Brothers Notre Dame of Kidapawan College First Semester, AY 2023-2024 Kidapawan City Midterm Examinations October 10-13, 2023 ELEC3 - Event-Driven Programming Mar Lou P. Galinato, ECE, MEP Name: ____________________________________________ Program/Year: ________________________________ TEST I. MULTIPLE CHOICE [2 PTS EACH] Please exercise caution when marking your answers by shading the letter corresponding to your choice for each item. It is essential to note that any attempts to erase or correct your selections will be deemed incorrect. [1] In the context of Android app development, what is an event in event-driven programming? [A] A physical gathering of developers [B] A user action or system occurrence (e.g., button click, sensor input) [C] A function that calculates mathematical operations [D] A graphical user interface element [2] Which programming paradigm is commonly associated with event-driven programming in Android Studio? [A] Object-Oriented Programming (OOP) [B] Procedural Programming [C] Functional Programming [D] Event-Driven Programming [3] How does event-driven programming differ from procedural programming in the context of Android app development? [A] Event-driven programming focuses on defining procedures for handling events, while procedural programming follows a step-bystep sequence of instructions. [B] Procedural programming relies on events to execute code, while event-driven programming follows a structured set of functions. [C] Event-driven programming and procedural programming are essentially the same and can be used interchangeably. [D] Procedural programming is used exclusively for desktop applications, while event-driven programming is used for mobile apps. [4] You are developing a simple Android app that plays a sound when a button is clicked. Describe the key components and steps involved in implementing this event-driven functionality using Android Studio. [A] Create a button, write code to play the sound, and assign the code to the button's click event handler. [B] Create a button, add a sound file to the project, and assign the sound file to the button's properties. [5] [C] Create a button, add a sound file to the project, and the sound will play automatically when the app is launched. [D] Create a button, write code to play the sound, and the sound will play when the app is installed. You are tasked with creating an Android app that responds to the device's accelerometer sensor by changing the background color when the device is shaken. How would you implement this eventdriven functionality in Android Studio? [A] Create a button and write code to change the background color when the button is clicked. [B] Create a button and assign the accelerometer sensor to it to change the background color. [C] Create a sensor event handler, listen for accelerometer data, and write code to change the background color when a shake is detected. [D] Create a timer to periodically change the background color regardless of sensor input. [6] You are developing a music player app in Android Studio. Explain how you would use event-driven programming to allow users to pause and resume playback by tapping on the album artwork displayed on the screen. [A] Create a button for pausing and resuming playback and assign it to the album artwork. [B] Create a gesture event handler to detect taps on the album artwork, and write code to pause and resume playback based on the tap events. [C] Create a separate screen for playback controls and use buttons for pausing and resuming playback. [D] The album artwork cannot be used for pausing and resuming playback in event-driven programming. [7] Analyze the advantages of using event-driven programming in Android app development compared to other programming paradigms. What specific scenarios benefit from event-driven programming? [A] Event-driven programming is not suitable for Android app development. [B] Advantages include responsiveness to user interactions, efficient handling of asynchronous events, and modularity. It is beneficial in scenarios where user interactions trigger various actions and events. [C] Event-driven programming is only suitable for web development, not for Android apps. [D] Event-driven programming is slower and less efficient compared to procedural programming. [8] [9] You are tasked with evaluating the performance and responsiveness of an Android app that heavily relies on event-driven programming. What factors would you consider in your analysis, and how would you address any performance bottlenecks or lag in event handling? [A] Factors include the complexity of event handlers and the number of events triggered. Address performance issues by simplifying event handlers and reducing the number of events. [B] Factors include the device's screen size and resolution. Address performance issues by using smaller screens. [C] Event-driven programming always results in lag and cannot be improved. [D] Performance is not affected by event-driven programming. What does XML stand for in the context of Android Studio's GUI design? [A] Extensible Markup Language [B] Extra Manipulation Language [C] Android Markup Language [D] Extensive Mobile Layout [10] Which file in an Android Studio project is commonly used to define the layout of a graphical user interface (GUI)? [A] MainActivity.java [B] build.gradle [C] activity_main.xml [D] AndroidManifest.xml [11] In Android Studio, what is the purpose of the "onCreate" method in an activity class? [A] It initializes the Android application. [B] It handles button clicks. [C] It sets the content view for the activity. [D] It defines the layout of the GUI. [12] Suppose you want to create a button in an Android GUI that, when clicked, opens a new activity. Which XML attribute should you use in the Button element to specify the target activity? [A] android:id [B] android:layout_width [C] android:onClick [D] android:targetActivity [13] You are building an Android app, and you need to create a registration form with several input fields. Describe the steps you would take to design the layout for this form in Android Studio. [A] Define the layout in XML, create corresponding Java classes, and link them. [B] Use the default Android form layout template. [C] Write the entire layout and functionality in Java code. [D] Use a third-party library for form design. [14] You have a scenario where you want to handle a long press event on a button in your Android app. Explain how you would implement this using Android Studio and Java. [A] Use a OnClickListener with a delay to simulate a long press. [B] Override the onLongClick method of the View.OnLongClickListener interface and set it as the button's long click listener. [C] Add a timer to the button and trigger the event after a specific duration. [D] Long press events are not supported in Android Studio. [15] You are working on an Android app with multiple activities. Explain the advantages and disadvantages of using explicit intent versus implicit intent for launching activities. [A] Explicit intents are faster, while implicit intents are more flexible. [B] Explicit intents are more secure, while implicit intents are less efficient. [C] Explicit intents are easier to implement, while implicit intents require more configuration. [D] Explicit intents are limited to launching activities within the same app, while implicit intents can launch activities from other apps. [16] You have a complex Android GUI with several nested layouts. Explain how optimizing the layout hierarchy can improve the performance of your app. [A] Reducing the depth of nested layouts can make the GUI rendering faster. [B] Increasing the number of nested layouts improves code maintainability. [C] Nesting layouts has no impact on app performance. [D] Optimizing the layout hierarchy is only relevant for web development, not for Android apps. [17] What is the primary purpose of the Android Main (UI) Thread? [A] To execute background tasks [B] To handle user interface interactions [C] To manage database operations [D] To perform network communication [18] What is an AsyncTask in Android Studio used for? [A] Creating new threads for UI tasks [B] Handling HTTP requests and responses [C] Running background tasks and updating the UI thread [D] Managing UI layout components [19] In Android, why is it important to perform timeconsuming operations such as network requests or file I/O tasks asynchronously? [A] To make the code cleaner and more readable [B] To improve the performance of the main UI thread [C] To ensure the app is compatible with older Android versions [D] To reduce the number of Java classes in the project [20] What is the purpose of the onPostExecute method in an AsyncTask? [A] To execute background tasks [B] To perform initialization operations [C] To update the UI after the background task completes [D] To handle user input events [21] You are developing an Android app that needs to download an image from a remote server and display it in an ImageView. Describe the steps you would take to accomplish this using asynchronous programming in Android Studio. [A] Use the Main (UI) Thread to download the image and display it. [B] Create a new AsyncTask to download the image in the background and update the ImageView in the onPostExecute method. [C] Use a synchronous network call to download the image directly on the main UI thread. [D] Use a separate service to download the image and broadcast an Intent to update the ImageView. [A] Enhancing the visual aesthetics of the app [B] Improving the app's performance and speed [C] Creating a positive and user-friendly interaction for the users [D] Increasing the app's download count on the Google Play Store [26] Which of the following is an essential aspect of Interaction Design in Android app development? [A] Writing efficient code for the app's backend [B] Designing the app's logo and branding elements [C] Defining how users interact with the app's interface and features [D] Conducting market research to identify target audiences [22] How does Android Studio handle UI interactions and background tasks in the context of the Android Event Loop? [A] All UI interactions and background tasks run on the same thread to ensure consistency. [B] UI interactions run on the Main (UI) Thread, and background tasks run on separate threads to prevent UI freezing. [C] UI interactions and background tasks are handled by the operating system and do not require any special handling. [D] Background tasks run on the Main (UI) Thread to ensure synchronization with UI interactions. [27] Explain the concept of "affordance" in the context of Android app design. [A] Affordance refers to the visual appeal of an app's user interface. [B] Affordance is the ease with which users can perform actions based on the app's design cues. [C] Affordance is a measure of how many features an app can offer to users. [D] Affordance is only relevant for web design, not for mobile apps. [23] Imagine you have an Android app with multiple asynchronous tasks running concurrently. What potential issues or challenges could arise from improper management of these asynchronous tasks? [A] Improved app responsiveness and faster execution [B] Increased risk of memory leaks and crashes [C] Easier debugging and error handling [D] Compatibility with a wider range of Android devices [24] Compare and contrast the use of AsyncTask and Kotlin's Coroutines for handling asynchronous tasks in Android Studio. Discuss their advantages and disadvantages. [A] AsyncTask is older and more reliable, while Coroutines offer better performance and readability. [B] AsyncTask and Coroutines are functionally equivalent and can be used interchangeably. [C] AsyncTask is better for long-running tasks, while Coroutines are ideal for short, simple tasks. [D] AsyncTask is deprecated, and Coroutines provide a more modern and flexible way to handle asynchronous tasks. [25] What is the primary goal of User Experience (UX) design in Android app development? [28] How can the use of consistent navigation patterns, such as the Android Bottom Navigation Bar, contribute to a better user experience in an app? [A] It adds unnecessary complexity to the app's navigation. [B] It allows users to switch between different apps seamlessly. [C] It ensures that users can easily access common app sections and features. [D] It provides additional security layers for the app. [29] You are designing an Android app for a news website. Describe how you would apply the principle of "content-first" design to ensure a positive user experience. [A] Place advertisements prominently to increase revenue. [B] Prioritize visual elements over text to make the app more appealing. [C] Focus on presenting news articles and headlines in a clear and accessible manner. [D] Use complex animations and transitions to engage users. [30] How would you apply the concept of "usability testing" in Android app development to improve the user experience? [A] Test the app on a single device and make it available for download. [B] Conduct surveys to gather feedback from users after the app's release. [C] Invite a group of target users to perform specific tasks within the app and gather feedback based on their experiences. [D] Hire a team of designers to conduct an internal review of the app's design. [31] Consider an Android app with a complex user interface and multiple interaction elements. Explain how the use of "information architecture" can contribute to better user experience and interaction. [A] Information architecture primarily focuses on enhancing the app's visual design. [B] Information architecture helps organize content and interactions logically, making it easier for users to navigate and understand the app. [C] Information architecture is irrelevant in modern app design. [D] Information architecture is only important for e-commerce apps. [32] Compare and contrast the concepts of "usercentered design" and "system-centered design" in the context of Android app development. Discuss their impact on user experience. [A] User-centered design prioritizes user needs and preferences, while system-centered design focuses on technical requirements. Usercentered design typically results in a better user experience. [B] User-centered design and system-centered design are interchangeable terms with no significant differences. [C] User-centered design prioritizes technical requirements, while system-centered design focuses on user needs. System-centered design typically results in a better user experience. [D] User-centered design is only relevant for smallscale apps, while system-centered design is more suitable for large enterprises. [33] What is the primary purpose of Event-Driven Design Patterns in Android Studio? [A] To optimize code for better performance. [B] To enhance the user interface design. [C] To handle and respond to user interactions and system events. [D] To automate the testing process. [34] Which of the following best describes the Observer Pattern in Android's Event-Driven Design? [A] It defines a one-to-one dependency between objects. [B] It allows an object to notify its dependents about changes without knowing who or what those dependents are. [C] It specifies how to create objects in a way that they can be substituted with their subclasses. [D] It ensures that only one instance of a class is created and provides a global point of access to that instance. [35] Imagine you are building a music player application in Android Studio. How would you apply the Observer Pattern to update the user interface when a new song is played? [A] Implement a BroadcastReceiver to handle song change events. [B] Create a custom listener interface for song changes, and have the UI components register as listeners. [C] Use a Singleton pattern to manage song data and update the UI directly. [D] Poll the song data at regular intervals and update the UI when changes are detected. [36] In Android Studio, you are designing an application that uses multiple event-driven design patterns, including the Observer Pattern and the Command Pattern. How would you analyze the interactions between these patterns to ensure efficient event handling? [A] Implement both patterns in separate modules and let them communicate directly. [B] Use a Mediator Pattern to decouple the Observer and Command patterns, facilitating communication between them. [C] Embed the Command Pattern within the Observer Pattern to simplify event handling. [D] Combine all patterns into a single monolithic structure to reduce complexity. TEST II. DESIGN PROBLEM [150 PTS] [37] Basic Basketball Scoreboard Android App Development PROBLEM DESCRIPTION: You are tasked with developing a basic Android app for a basketball scoreboard. The app should allow users to keep track of the time, shot clock, team scores, team fouls, and the current quarter of a basketball game. Your objective is to create this app and provide a grading rubric to evaluate the solutions submitted by students or developers. APP REQUIREMENTS: 1. Scoreboard Display: The app should display the following information for an ongoing basketball game: Current time (in minutes and seconds) remaining in the game. Shot clock time (in seconds). Scores for both teams, showing points scored by each team. Team fouls for each team. The current quarter or period of the game. 2. User Interaction: Users should be able to interact with the app by: Starting, stopping, and resetting the game clock. Manually adjusting the game time, shot clock, scores, and team fouls. Implementing a user-friendly interface for referees or scorekeepers to easily update the scoreboard during a game. 3. Game Control: Include features to control the game state, such as: Starting or pausing the game clock. Resetting the shot clock after an offensive rebound. Advancing to the next quarter when appropriate (e.g., after four quarters in a typical basketball game). 4. Visual Feedback: The app should provide visual indicators, such as color changes or icons, to make it clear when the shot clock is about to expire or when a team reaches a bonus or penalty situation. 5. Settings: Users should have basic settings options to customize the app, such as adjusting the game clock increment and configuring team names/colors. 6. Simplicity: The app should prioritize simplicity and ease of use, making it suitable for both casual users and basketball referees. GRADING RUBRIC: Below is a rubric to evaluate the solutions submitted for this Android app development problem. Each criterion is assigned a point value, and the total points will determine the grade. 1. User Interface (30 points): Intuitive and clutter-free design (10 points). Legible fonts, icons, and clear information presentation (10 points). Support for both portrait and landscape orientations (10 points). 2. Functionality (40 points): Accurate and precise timekeeping functionality (15 points). Proper control of the game state, including clock start/stop, shot clock reset, and quarter advancement (15 points). Responsive user interaction and controls (10 points). 3. Customization and Settings (20 points): Implementation of settings to customize app behavior (10 points). Configuration options for team names/colors (10 points). 4. Visual Feedback and Notifications (15 points): Effective use of visual indicators (10 points). Implementation of sound notifications for critical events (e.g., shot clock buzzer) (5 points). 5. Code Quality (25 points): Well-structured code and adherence to Android best practices (15 points). Proper error handling for user input and app state changes (5 points). Efficient use of resources and optimization (5 points). 6. Documentation and Comments (10 points): Clear and well-documented code (5 points). 7. Helpful comments that explain key code segments (5 points). Bonus (10 points): Additional features or enhancements beyond the basic requirements (e.g., historical game data, multiple game support). TOTAL POINTS: 150 You are responsible for evaluating the submitted solutions based on this rubric, providing feedback, and assigning grades accordingly. The bonus points section allows for recognizing exceptional work that goes beyond the basic requirements. -x-x-x-End of Test-x-x-x-