MAD final exam Flashcards
Define the following terms related to mobile app development:
i. APK
ii. SDK
iii. UI/UX
APK = android package kit/android application package. a file format used to install applications on android devices. consists of (Manifest file, resources(images, XML layout files), Dalvik(runs application
SDK= Software development kit. collection of tools and libraries and documentation used to build apps for a specific platform.
User interface/ User Experience. design ad functionality of an app that affects how users interact with it
- Discuss the purpose of AndroidManifest file and its further details. 9. Draw a skeletal structure of this file.
crucial file bcz it serves a configuration file for the app. proovides essential info to the android system.
declares app components. activities, services, broadcast receivers and content providers.
sets permission. sprcific permision are so dat the app needs to acess system features or user data.
declare intents and filters. defines intents and filters for communication components within the app and other apps.
specify app icon and name. as its set they appear in the app launcher.
Differentiate between Java and Kotlin in Android development. What are the advantages of using
Kotlin?
kotlin is interoperability(coexist with java in aandroid projects),
builtin null safety to prevent null ponter exceptions while java’s null safety requires explicit null checks
kotlin is newer
advantages
-enhanced cod readability(easy to understand and maintain)
better null safety
-reduced bolierplate code(less repetitive code = fewer errors and faster development)
List and briefly describe the four main components of an Android application. Provide an example
use case for each component.
activities. represents a single screen within an app e.g login screen
services. runs in background , performs long-running tasks. e.g music player service , location tracking service
broadcast receivers. respond to system wide or application specific events e.g incoming calls , battery status reciever.
content providers. manges and persists data that can be shared by multiple apps. e,g contact list provider.
What is the purpose of an Intent in Android? Explain the difference between an explicit intent and
an implicit intent
message passing mechanism . it communicates between components within an app or between different apps.
explicit intents. directly specify the target component( e.g activity, service) by its class name. used for internal communication within an app or to start specific components in other apps.
implicit. specify the action to be performed and the data to be used. allows other apps to to handle the intent if they have the appropiate filters. used to open web pages , send emails , amke calls
How does the Android activity lifecycle work? List and briefly explain the key lifecycle methods of
an Android activity.
onCreate():
Called when the activity is first created.
onStart(): Called when the activity becomes visible to the user.
onResume(): Called when the activity starts interacting with the user.
onPause(): Called when another activity is about to take focus.
onStop(): Called when the activity is no longer visible to the user.
onDestroy(): Called when the activity is being destroyed.
onRestart(): Called when the activity is being restarted after having been stopped.
Describe the role of a content provider in Android. Provide an example scenario where a content
provider would be useful
What is RecyclerView, and why is it commonly used in Android app development? Provide a code
example of implementing a simple RecyclerView.
RecyclerView is a versatile view in Android used for displaying large lists of data efficiently. It recycles views that scroll off the screen, improving performance and reducing memory usage.
//check the slides
Explain the concept of threading and concurrency in Android. Why is it important, and what are
some methods to achieve multithreading in Android apps?
Threading in Android allows multiple threads to run concurrently, enabling tasks to be performed in the background without blocking the main UI thread.
Concurrency is the ability of an application to perform multiple operations simultaneously.
Importance:
Threading is crucial for maintaining a responsive user interface and ensuring that time-consuming tasks (like network operations or database access) do not freeze the app.
Methods to achieve multithreading in Android:
AsyncTask: Simplifies background operations and updates the UI. Handler: Allows communication between threads and the main UI thread. Executors: Provides a high-level API for managing threads and task execution. Coroutines: A modern approach for asynchronous programming that simplifies code and improves readability.
Using these methods helps improve app performance and user experience.
Briefly discuss the Model-View-Controller (MVC) architectural pattern and its relevance in Android
development. Provide an example of how MVC can be implemented in an Android app.
- Draw an android stack overview and label it fully (revise session 4a and session 3a)
- Explain the Linux and Native layers of the Android Architecture Stack (session 4a and 3a)
Linux Layer:
The Linux layer serves as the foundation of the Android architecture, providing essential services such as hardware abstraction, process management, memory management, and security features. It includes the Linux kernel, which interfaces directly with the hardware and manages system resources.
Native Layer:
The Native layer consists of C/C++ libraries that provide core functionalities for Android apps, including graphics (Skia), database management (SQLite), and web rendering (WebKit). This layer allows developers to access lower-level hardware features and optimize performance for resource-intensive applications.
- Discuss Virus, Malware and Spyware, explain why they would affect android apps.
Virus: A malicious program that replicates itself and spreads to other devices, potentially damaging files or systems.
Malware: A broad term for any malicious software designed to harm or exploit devices, data, or networks (includes viruses, ransomware, etc.).
Spyware: A type of malware that secretly monitors user activity and steals personal information.
- Discuss why we would use a native platform to develop android applications.
Optimal Performance: Native apps have direct access to device hardware, providing faster and more efficient performance.
Full Access to Features: Native development allows access to all Android features (camera, sensors, etc.) and APIs.
Better User Experience: Native apps integrate seamlessly with the Android system, ensuring smoother UI and UX.
Security: Native platforms provide robust security features and updates for Android apps.
- What similarities and differences are there between Windows and Android architectures.? 6. Draw well labeled diagrams to differentiate the two.
Similarities:
Layered Architecture: Both Windows and Android have layered architectures, with hardware at the bottom and applications at the top. Kernel: Both use a kernel for core system services (Android uses Linux, while Windows uses the Windows NT kernel). User Interface: Both provide a GUI for user interaction with applications. Security: Both have built-in security features like access control and user permissions.
Differences:
Kernel: Android uses the Linux kernel, while Windows uses the Windows NT kernel. Application Framework: Android uses a Java-based application framework, while Windows apps are built using various technologies (e.g., .NET, C++). User Interaction: Android is optimized for touch-based interaction, while Windows traditionally supports both touch and desktop-based interactions. App Distribution: Android apps are distributed through the Google Play Store, while Windows apps are distributed via the Microsoft Store and other sources.
- Discuss the key features of Android studio that you find useful for application development.
Intelligent Code Editor: Provides code suggestions, error checking, and refactoring tools.
Layout Editor: Drag-and-drop interface for designing UI components with real-time previews.
Gradle Build System: Manages project dependencies, builds, and APK generation.
Emulator: Allows testing apps on virtual devices without needing physical hardware.
Debugging Tools: Advanced tools like the debugger, logcat, and profiler for troubleshooting and optimizing performance.
- List and discuss any 5 Resource files found in the android app file structure.
- Differentiate between a class and an object in Kotlin, use sample codes for further elaboration of your understanding.
a class in a blueprint of a class while an object is an instance of a class.
class Car(val model: String, val year: Int) {
fun start() = println(“$model is starting.”)
}
// Creating an instance (object) of the class
val car = Car(“Toyota”, 2020)
car.start() // Output: Toyota is starting.
——————————————————————————————————————————–
object MySingleton {
val name = “SingletonObject”
fun display() = println(“This is a singleton object.”)
}
// Accessing singleton object
MySingleton.display() // Output: This is a singleton object.
- What is an Activity? Draw an activity lifecycle diagram and main methods and different life stages. (Session 4b)
-Preserve user data and state if:
User temporarily leaves app and then returns
User is interrupted (for example, a phone call)
User rotates device
-Avoid memory leaks and app crashes.
- Show how a constructor is created in Kotlin class, show a constructor with parameters and no parameters
Primary Constructor (with parameters):
class Person(val name: String, val age: Int)
Secondary Constructor (no parameters):
class Person {
constructor() {
println(“No-argument constructor”)
}
}
What is the purpose of the initializer block? Show code which implements it.
initializer block in Kotlin is used to execute code when an instance of a class is created, especially for complex initialization.
class Person(val name: String) {
init {
println(“Person’s name is $name”)
}
}
val person = Person(“Alice”) // Output: Person’s name is Alice
- How do we show properties in an android class, show with an example
properties in a class are defined using variables. class User(val name: String, var age: Int)
val user = User(“John”, 25)
println(user.name) // Access property ‘name’
user.age = 26 // Modify property ‘age’
- How do show inheritance in a Kotlin, demonstrate with sample code
inheritance is shown using the open keyword for the base class and : for subclassing.
open class Animal {
fun eat() = println(“Eating”)
}
class Dog : Animal() {
fun bark() = println(“Barking”)
}
val dog = Dog()
dog.eat() // Inherited method
dog.bark() // Dog’s own method