Quiz
Mobile midterm
This quiz has question types that open in the usual player.
Questions in this quiz (39)
1To create a click event for a button, there are 2 ways:
Using onClick============
XML:
android:onClick="name"
code:
public void name (View view) {
//code
}
using click listener===========
Button btn = findViewById(R.id.name);
btn.setOnClickListener(new View.OnClickListener() {
@override
public void onClick (View v) {
//code
}
});- ATrue
- BFalse
2Which of these layouts are most commonly used in our projects:
- AConstraintLayout
- BLinerLayout
- CFrameLayout
- DRelativeLayout
3Toasts:
Toast.makeText(this, "hello", Toast.LENGTH_LONG).show();- ATrue
- BFalse
4OnClick in XML
Advantages:
Easy to implement
Disadvantages:
Only available in OnClick event
callback method must be in parent activity- ATrue
- BFalse
5Inner class listener
Advantages:
Can use all events
Disadvantages:
harder to implement- ATrue
- BFalse
6Widgets are design time created, when inflated it becomes a view
- ATrue
- BFalse
7Button hierarchy:
Textview
^
Button
^
CompoundButton
^
CheckBox, RadioButton, Switch, ToggleButton- ATrue
- BFalse
8RadioButtons require a parent RadioGroup, which is a subclass of LinerLayout
- ATrue
- BFalse
9Spinners are a drop down selection of items that can be selected.
Usually uses a string-array in string.xml to populate it.
Can set the array in xml or by using an ArrayAdapter.
Selected values can be get using getSelectedItemPosition or getSelectedItem.- ATrue
- BFalse
10this vs MainActivity.this
When the method call is directly within the Activity, use this
When the method call is within an inner class, use MainActivity.this- ATrue
- BFalse
11Model View Controller (MVC) is a software design pattern used in developing apps.
Useful for separating areas of responsibility in the app.- ATrue
- BFalse
12Model of the MVC, is composed of objects that make up the data of the app.
ie. Student class, Employee class etc- ATrue
- BFalse
13View of MVC, is what the user sees and interacts with, handles the look and feel.
- ATrue
- BFalse
14Controller of MVC, acts as a go-between between view and model. View takes user input, sends to controller, controller has logic to process the input by calling the model objects to process the input.
- ATrue
- BFalse
15MVC
Model: implemented by programmer
View: XML, widgets
Controller: activities act as controllers- ATrue
- BFalse
16Benefits of packages (putting Student class in a folder)
-group classes
-avoid naming conflicts
-protect classes- ATrue
- BFalse
17Packages are hierarchical (android.app.Activity, Activity is within app package)
Package names must be unique and lowercase
To access a package, import it (import java.app.package_name)- ATrue
- BFalse
18Dont use findViewByID before OnCreate as its initially just a java object before OnCreate is called.
Spinner spn = find.....
protected void OnCreate(...){
...
}- ATrue
- BFalse
19Activity is like a screen,
handles interaction with the user
Do not keep instance data (clears when refreshed)- ATrue
- BFalse
20Activity lifecycle
- Athis
- Bno
21Usually when configuration changes in a app occur, OnDestory() is called followed by OnCreate()
- ATrue
- BFalse
22Bundles can be used on OnSaveInstanceState and OnRestoreInstanceState to prevent the app from resetting its state entirely.
- ATrue
- BFalse
23OnResume() is a safe place to put SharedPreferences code
- ATrue
- BFalse
24Pros of SharedPreferences:
quick and easy way to store info
access value using name-value pair
not visible to other apps
cons:
limited data storage
cannot control where data is stored- ATrue
- BFalse
25Pros of File I/O:
better for storing large data
can create/store any type of data
multiple places can be stored in
cons:
more coding- ATrue
- BFalse
26Pros of SQLite:
flexibly on storage
ability to use querys for data
performs updates transactionally
robust for storing relational data
cons:
more coding
requires knowledge on SQL
overkill for simple data saving- ATrue
- BFalse
27When using SharedPreferences, use must call apply() or commit() to save the changes
clear() will wipe all values- ATrue
- BFalse
28Context is an abstract class, implemented by android systems
allows access to specific resources and classes- ATrue
- BFalse
29Intents are used to create more loosely coupled apps, and allows your app to call services from other apps
- ATrue
- BFalse
30Intents can be explicit:
calling a specific services
Or implicit:
let run-time or user pick the activity to handle the intent- ATrue
- BFalse
31With Intents, to set the action property, use Intent.ACTION_VIEW
set the data property to be URL needed
Intent (string action)
Intent (string action, URL)
Intent (Context context, class)- ATrue
- BFalse
32startActivity - launched and independent of launching activity
startActivityForResult - launched as sub-activity of launching activity and returns a result- ATrue
- BFalse
33Returning result from sub-activity using setResult
setResult(int response) - returning a success or failure
setResult(int response, Intent intent) - returning additional information- ATrue
- BFalse
34passing data from activity to another activity, using Intent
intent.putExtra("data", "from parent")
Getting the data:
data = intent.getStringExtra("data")- ATrue
- BFalse
35ActionBar is the portion on top of the app that contains icons for additional control of the app.
- ATrue
- BFalse
36Creating an options menu for an app:
creating an xml layout for the menu
hooking up the menu to activity
To respond to the menu interaction:
use onOptionsItemSelected- ATrue
- BFalse
37PreferenceActivity:
works along SharedPreferences
is XML-based
uses components which are subclasses of preference
UI file is stored in a folder called xml (use must create it)- ATrue
- BFalse
38Preference class:
represents basic UI building block for PreferenceActivity screens
Four main subclasses:
DialogPreference
PreferenceGroup
TwoStatePreference
RingtonePreference- ATrue
- BFalse
39Android Studio Stack

- Ahai Upma <3
- Bno
Information
- Description
- Computer Science Quiz on Mobile midterm, created by Duncan Levings on 17/10/2018.
- Author
- Duncan Levings
- Language
- English
- Views
- 6
- Tags
- Rating
- No ratings yet Rate this quiz