Docsity

ANDROID BOOT CAMP FOR DEVELOPERS USING JAVA COMPREHENSIVE EXAM SCRIPT VERIFIED QUESTIONS A, Exams of Java Programming

Toggle sidebar
bg1
ANDROID BOOT CAMP FOR DEVELOPERS
USING JAVA COMPREHENSIVE EXAM
SCRIPT VERIFIED QUESTIONS AND
SOLUTIONS GRADED APLUS
●● State
Answer: This is when an object encompasses all of the (typically static)
properties of the object plus the current (typically dynamic) values of
each of those properties. In other words, an object has this when it
associates values (numbers, strings, arrays, etc) to a property and a point
of time.
●● Method Override
Answer: A child class can override a method of the parent class. What
this means is that this can be invoked differently depending on if it's
invoked in the child or parent class.
●● Method Overload
Answer: A single method may perform different functions depending on
the context in which it's used. I.e. a single method might work in
different ways depending on the arguments passed to it
●● Universally Unique Identifier (UUID)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31

Partial preview of the text

Download ANDROID BOOT CAMP FOR DEVELOPERS USING JAVA COMPREHENSIVE EXAM SCRIPT VERIFIED QUESTIONS A and more Exams Java Programming in PDF only on Docsity!

ANDROID BOOT CAMP FOR DEVELOPERS

USING JAVA COMPREHENSIVE EXAM

SCRIPT VERIFIED QUESTIONS AND

SOLUTIONS GRADED APLUS

●● State Answer: This is when an object encompasses all of the (typically static) properties of the object plus the current (typically dynamic) values of each of those properties. In other words, an object has this when it associates values (numbers, strings, arrays, etc) to a property and a point of time. ●● Method Override Answer: A child class can override a method of the parent class. What this means is that this can be invoked differently depending on if it's invoked in the child or parent class. ●● Method Overload Answer: A single method may perform different functions depending on the context in which it's used. I.e. a single method might work in different ways depending on the arguments passed to it ●● Universally Unique Identifier (UUID)

Answer: A class that represents an immutable. This represents a 128-bit value. There exist different variants of these global identifiers. The methods of this class are for manipulating the Leach-Salz variant, although the constructors allow the creation of any variant of this ●● APK (Android application Package) Answer: Package file format used by the Android OS for the distribution and installation of apps, games, and middleware ●● SQLite Answer: A software library that provides a relational database management system. This has the following attributes: self-contained, serverless, zero-configuration, and transactional. ●● Self-Contained Answer: SQLite requires minimal support from the operating system or external libraries. This makes SQLite usable in any environment including embedded devices such as iPhones, Android Phones, game consoles, handheld media players, etc. ●● Serverless Answer: Simply means that SQLite does not require a server to run (unlike MySQL, PostgresQL, etc. which require a server to run)

●● Intent Filter Answer: This is an expression in the app's manifest file that specifies the types of intents that the app would like to receive. By declaring this for an activity, this makes it possible for other apps to directly start the activity with a certain type of intent. Example: The code block below tells the Android system to view a webpage. All currently installed web browsers on the device should be registered to the intent data via this. ●● Test Runner Answer: A library or tool that picks up a source code directory (or an assembly) that contains unit tests, and then executes the test and writes the results to the console or log files. ●● Assembly Answer: A collection of types and resources that are built to work together and form a logical unit of functionality ●● Unit Testing Answer: A software testing method in which individual units of source code, usage procedures, operating procedures, and sets of one or more computer program modules together with their associated data, are tested to determine whether they are fit for use. In other words, Unit Tests are generally automated tests written and run by developers to ensure that a section of an application (known as the "unit") meets its design and behaves as expected. In OOP, a unit is often an entire interface, such as a class, but can also be an individual method.

●● Test-Driven Development (TDD) Answer: A software development process that relies on the repetition of a very short development cycle. The requirements for the section are turned into very specific test cases, then the code is improved so that the test passes. The cycle generally follows this flow:

  1. Add a test: Makes the developer think about the requirements before writing the code.
  2. Run all tests and see if the new test fails: Shows that the test harness (a collection of tests) is working properly. Also shows if the new test is flawed by always succeeding.
  3. Write the code.
  4. Run tests.
  5. Refactor code ●● Test Case Answer: A specification of the inputs, execution conditions, testing procedure, and expected results of a single test. This test is intended to achieve a specific testing objective. ●● Mock Object Answer: Simulated objects that mimic the behavior of real objects in controlled ways, most often as a part of testing. These are typically created to test the behavior of some other object.

any notification that the memory block has changed. Cache Coherence is intended to manage such cache conflicts by maintaining a coherent view of the data in multiple caches. ●● Singleton Answer: This pattern only allows a class to create a single instance of itself in the entire runtime of the app. These classes are typically used for logging, driver objects, database connections, caching pools, and thread pools. This can be achieved by making the constructor private. ●● Collections Answer: This is a group of objects represented as a single unit. These allow all classes within it (Arrays, Vectors, Lists, etc) to be represented by a set of common methods. Example: Your app stores data in an object of type People. You can then store multiple People type objects within this. ●● Thread Answer: This is an independent path of execution within a program. Many of these can run concurrently, either asynchronously or synchronously, within the program. All of these can be categorized into two basic categories: Such that ARE attached to an activity/fragment: These are tied to the lifecycle of the activity/fragment and are destroyed as soon as the activity/fragment are destroyed Examples: Kotlin Coroutine, AsyncTask, RxJava, Loaders

Such that ARE NOT attached to an activity/fragment: These can continue to run beyond the lifetime of the activity/fragment from which they are created. Examples: Service, IntentService ●● Main Thread Answer: This is the first thread of execution created within an Android application when the app is first launched. This is responsible for dispatching events to the appropriate UI widgets as well as communicating with the components from the Android UI toolkit. Due to this reason, this should NOT perform any actions that may block it as that will cause the app to become unresponsive. This is not suitable for network operations and database calls as well as the loading of certain components. These are called synchronously in the main thread, which essentially blocks the main thread until the operation is complete. For this reason they are typically performed in separate threads (see: Coroutines, AsyncTask, RxJava, etc.) to be run asynchronously. ●● OOP Answer: Object Oriented Programming has four core concepts:

  1. Abstraction: Represent complexity with simple items. Objects, Classes, and Variables are forms of abstraction which represent the more complex code and data that lies underneath.
  2. Encapsulation: Encapsulation is the practice of keeping fields within a class private. Access can be given to outside classes through utilizing public methods within the original class. Encapsulation allows the data

data to lists, etc. onCreate also provides the activity with a bundle of its previous state. onCreate is always followed by onStart()

  • onStart(): Called when the activity is becoming visible to the user. onStart is followed by onResume() if the activity is coming to the foreground, or onStop() if the activity becomes hidden.
  • onResume(): Called when the activity will start interacting with the user. At this point, activity is at the top of the activity stack with the user input going into it. onResume is always followed by onPause()
  • onStop(): Called when the activity is no longer visible to the user (goes to the background). This can happen if a different activity is being started on top of the current activity, a preexisting activity is being brought back to the foreground, or the current activity is being destroyed. onStop is typically used to stop animations and also for refreshing the UI. onStop is followed by either onRestart() if the activity is coming back to the foreground to interact with the user or onDestroy() if the activity is being removed.
  • onPause(): Called with the activity loses its foreground state, is no longer focusable, or before the transition to stopped/hidden or destroyed. The activity is still visible to the user at this point so it's recommended to keep the activity visually active and continue updating the UI. onPause is followed by either onResume() or onStop()
  • onRestart(): Called after onStop() when the current activity is being re- displayed to the user (the user has navigated back to the activity). Followed by onStart() then onResume().
  • onDestroy(): Called when the activity is being removed. This can happen if the activity is finishing (Activity#finish

●● Task Answer: This is a collection of activities that users interact with when performing a certain job. In Android, the reuse of other application components is a concept known as a task. An application can access other Android components to achieve this. Example: A component within an application you created can trigger an external component in the Android system that manages photos. In this photo component, you can select a photo and then return the photo to your application. ●● Service Answer: This is a component that runs in the background to perform long-running operations without needing to interact with the user. These work even when the application has been destroyed. This has two states: Started: These are started when an application component (i.e. an activity) starts it by calling startService(). Once started, this can run in the background even if the application is destroyed. Bound: These are bound when an application component binds to it by calling bindService(). Bound offers a client-server interface that allows components to interact with this, send requests, and get results. ●● Broadcast Receiver Answer: This is an android component that allows you to register for system or application events. Some system events include when the system boots up or when the device starts charging. Applications can

events to the Model. The View Model also receives the raw data from the Model and converts it into more presentation-friendly properties. The View Model should only know about the application context and should never be able to interact directly with the View (i.e. start an activity, inflate a layout, show a dialog) ●● JetPack Answer: This is a suite of quality of life libraries, tools, and guidance to help developers write apps more easily. This reduces the amount of boilerplate code, simplifies complex tasks, and helps developers follow best practices. This also comprises the androidx package libraries which are unbundled from the platform APIs. This means that this offers backwards compatibility and is updated more frequently than the Android platform. This is arranged into four major categories: Foundation Components: Provides backwards compatibility, testing, and Kotlin language support. The components are as follows: App Compat, Android KTX, Multidex, and Test Architecture Components: Assists developers in building robust, testable, and maintainable apps. Contains the following components: Data Binding, Lifecycles, LiveData, Navigation, Paging, Room, View Model, and Work Manager Behavior Components: Helps in integrating Notifications, Permissions, Sharing, and Assistant. Made up of: Download Manager, Media & Playback, Notifications, Permissions, Preferences, Sharing, and Slices. UI Components: Provides widgets and helpers to make the app easier to use as well as look better. Components: Animation and transitions, Auto, Fragments, Layouts, Palette, TV, Wear, and Emoji

●● GSON

Answer: A Java library that can convert Java Objects into their JSON (JavaScript Object Notation) representations. This can also be used to convert a JSON into an equivalent Java Object. ●● Moshi Answer: A JSON library for Android and Java that is used for parsing JSON into Java Objects. This can also serialize Java Objects as JSON. This is better than GSON due to:

  • Ships a smaller APK
  • Serialization failure messages are easier to read
  • Default values
  • Will not leak implementation details of platform types into encoded JSON
  • Faster and less memory usage
  • GSON is no longer updated while Moshi is being updated
  • Less issues around null safety and handling of custom classes such as Date and UUID ●● ViewModel Answer: A class responsible for preparing and managing the data for an activity or fragment (View). Also handles the communication of the Activity/Fragment (View) with the rest of the application (i.e. calling the

●● AsyncTask Answer: An abstract class provided by Android that allows the developer to perform heavier tasks in the background and keep the UI thread light. This creates a second thread to run tasks such as API fetch calls so that said fetch calls do not block the main thread, which would make the application unresponsive. The results from this secondary thread are passed back to the main thread. The main methods of this are:

  • doInBackground(): Contains the code that needs to be executed in the background. The results can be sent to the main thread through using
  • publicProgress(). Uses a return statement to exit once the background process is complete.
  • onPreExecute(): Contains code that executes before the background process starts
  • onPostExecute(): Contains code that executes after the background process completes. The result from doInBackground() is passed to this method.
  • onProgressUpdate(): Receives data from doInBackground() and publishes the data through publishProgress(). ●● LiveData Answer: A data holder class that can be observed (with an observer) within a given lifecycle. An observer can be added in a pair with a LifecycleOwner (a class that has an android lifecycle). The observer will only be notified about modifications of the wrapped data if the LifecycleOwner is in an active state. The class is used primarily for holding individual data fields of the View Model. The observer added

with a Lifecycle will automatically be destroyed when the host Lifecycle is also destroyed. This prevents data leaks. ●● Paging Answer: A library that helps load and display small chunks of data on demand. Loading partial data reduces usage of network bandwidth and system resources. ●● Navigation Answer: A framework for navigating between destinations within an Android application. The destinations can be Activities, Fragments, or some other components. this has 3 major components: NavGraph, NavController, NavHost. ●● NavGraph Answer: Navigation graph that encapsulates a set of destinations. In other words a NavGraph is a collection of NavDestination nodes fetchable by ID. Created by inflating a navigation XML file, constructing it programmatically, or a combination of the two. ●● NavController Answer: The NavController manages app navigation within a NavHost. The NavController is the main entry point for interacting with the Navigation Graph.

●● Room Answer: This persistence library adds an additional layer of abstraction over SQLite that allows for more robust database access while not losing any functionality from SQLite. This allows you to create a cache of your app's data on the device it's running on. The cache serves as the app's single source of truth and allows users to view a consistent copy of key information within the app, regardless of if the user has access to the internet. Room helps to reduce the amount of boilerplate code in your app (in comparison to simply using SQLiteDatabase), verifies SQL queries when your app compiles, and allows easy integration with other Architecture components (i.e. LiveData). Verifying SQL queries when your app compiles is good because it protects your app from crash issues at runtime and also allows it to check for syntax error and if there are missing tables. ●● WorkManager Answer: One of the Android Architecture Components and part of Android Jetpack. This is an Android library that runs deferrable background work when the constraints are satisfied. In other words, this allows you to schedule deferrable, asynchronous tasks that are expected to run even if the app exits or the device restarts. This is different from Kotlin Coroutines, RxJava, AsyncTasks, etc. in that those kill the background tasks upon the app exiting or device restarting. WorkManager is intended for tasks that do not destroy upon app exit or device restart. This is appropriate for:

  • Tasks that must finish: If the app closes, the task must still finish its process. Example: a remote sync (making a remote backup) of a note taking application with a server. After writing the note and closing the

app, you still expect the remote sync to happen. WorkManager would work well for this.

  • Tasks that are deferrable: If the task is only useful to us at the moment, then the task is NOT deferrable. If the task can be put off and run later without losing its usefulness, then the task is deferrable. Example: Using the note taking application example. It's nice if WorkManager can upload your note to the remote immediately. If this task is not currently possible, the task can be delayed until it is possible to execute the remote sync. WorkManager respects OS background restrictions and attempts to run its work in a battery efficient manner. ●● Retrofit Answer: This is a REST client used in Java and Android to create a HTTP request and also to process the HTTP response from a REST API. It makes it relatively easy to retrieve and upload JSON, XML, Jackson, etc. file(s) via a REST based web service. In other words, this is a type- safe HTTP client that makes it easy to consume JSON or other structured data which is parsed into Plain Old Java Objects (POJOs). This must have:
  • Model class(es) which is used as a JSON (or other structured data) model
  • Interfaces that define possible HTTP operations (GET, POST, etc.)
  • Retrofit.Builder class: An instance that uses the interface and Builder API to allow for the defining of the URL endpoints for the HTTP operations. ●● Intent