Build Your First Android App Quiz (Project-Centered Course) Answer. In this post you will get Quiz & Assignment Answer Of Build Your First Android App
Build Your First Android App Quiz (Project-Centered Course)
Offered By ”CentraleSupélec”
Week- 1
Quiz about Activities and GUI
1.
Question 1
What
is a view?
1 point
It
is a structure which organizes the position of the different
buttons, texts and images of the graphical user interface of your
application.
It
is a graphical element which can be used in the user interface of
your application.
It
is the layout of the screen displayed to the user and which serves
as an interface for your application.
2.
Question 2
Is it possible to use multiple views on a single screen of the graphical user interface of your application?
1 point
No
Yes
3.
Question 3
What
is the name of the views that allow you to organize the position of
the graphical components on the activity screen?
1 point
Enter answer here
Write anything. There is no right or wrong |
4.
Question 4
Is
it possible to nest a layout within another one?
1 point
yes
no
5.
Question 5
Android
buttons have a predefined style. The size and color of a button and
its text cannot be changed.
1 point
true
false
6.
Question 6
Associating
a name (unique id) to a view is mandatory when using what kind of
layout?
1 point
a relative layout
a
vertical linear layout
a
horizontal linear layout
7.
Question 7
Which actions can be triggered by a button click? (check all that apply)
1 point
start
a different activity
change
appearance of other views of the same activity
change
appearance of the button
8.
Question 8
When
an activity A starts an activity B (check all that apply):
1 point
the
activity A is paused or stopped
the
activity B comes to the foreground
the
activity A is destroyed
the activity B is not displayed immediately: it will come to the foreground only when the user presses the back button of the phone
9.
Question 9
Activities
are completely independent from one another, they cannot share data.
1 point
true
false
Quiz about Application Design
1.
Question 1
Which of these propositions describes a prototype?
1 point
low fidelity
middle to high fidelity, dynamic
high fidelity but static
2.
Question 2
Compared to mockups and prototypes, the amount of time necessary to create wireframes is
1 point
low
medium
high
3.
Question 3
Which usage or development phase are the prototypes most adapted to?
1 point
user testing, sometimes production of a reusable backbone
documentation, earliest iterations
gathering feedback and “selling” the visual side
4.
Question 4
What is the main characteristic of a mockup?
1 point
static visualization of final look
sketchy, black-grey-white representation of the interface
clickable
5.
Question 5
This application design seems flawed. Why?
1 point
The “Visualize” button does nothing.
The vertical LinearLayout in Screen2 includes an horizontal LinearLayout in its 3rd row.
The application starts with “Screen1”
but there is no path to “Screen3”.
6.
Question 6
What should you try to keep to a minimum when designing a mobile app?
1 point
The amount of data to be typed in by the user using the soft keyboard.
The number of buttons which call a given method.
The amount of information passed from one activity to another.
The number of activities.
Week- 2
Basic Knowledge about Android
1.
Question 1
Android Studio is:
1 point
A tool that allows to build and test Android applications.
A tool that allows to dump the memory of a smartphone.
A tool that allows to copy large files on a smartphone.
2.
Question 2
The AndroidManifest.xml file is a file that contains:
1 point
The variable and the methods of an activity
The resources of the application
The properties of the application
3.
Question 3
What is the purpose of the Android Virtual Device (AVD)?
1 point
Edit and compile Android applications
Modify the user interface of an application
Run and test Android application on an emulator
4.
Question 4
There is only one way to run and test an Android application from Android studio IDE.
1 point
False
True
5.
Question 5
The reason for selecting an older SDK release is that this ensures that the finished application will be able to run on the widest possible range of Android devices.
1 point
True
False
6.
Question 6
Give the name of the 2 most basic activity templates we use in general to build a basic Android application.
1 point
Empty Activity
Google Maps Activity
Login Activity
Scrolling Activity
Fullscreen Activity
Blank Activity
Create an interactive application
1.
Question 1
In the source code of an application, what function does it used to get a reference to a component of the user interface ?
1 point
findViewById()
setOnClickListener()
OnClick()
2.
Question 2
When an application is compiled a class named R is created. What does it contains ?
1 point
It contains references to the application resources
It contains references to the user interface resources
It contains a reference to the component properties of the user interface
3.
Question 3
The id property of a component can’t be modified ?
1 point
True
False
Week- 3
block 1
1.
Question 1
Which folder of your Android Studio project holds the XML files that describe the graphical interfaces of the MyApp application?
1 point
MyApp/app/gui
MyApp/app/manifests
MyApp/app/res/layout
MyApp/app/values
MyApp/app/res/drawable
MyApp/app/java
2.
Question 2
You have defined a graphical user interface in an XML layout file named myUI. You create a new activity in a file name MyActivity.java. How to you specify that MyActivity displays myUI?
1 point
In the onCreate method of MyActivity.java I use “myUI.display();”
In the onCreate method of MyActivity.java I call the setContentView method (without parameter) and in the root element of the myUI.xml file I indicate android:activity=”MyActivity”.
It’s impossible. Since the activity is named MyActivity, the system will try to load a layout named “activity_my.xml”.
In the onCreate method of MyActivity.java I use “”R.id.myUI.display();”
In the onCreate method of MyActivity.java I call the setContentView method and I provide “R.layout.myUI” as parameter.
In the onCreate method of MyActivity.java I call the onStart method and I provide “R.id.myUI” as parameter.
3.
Question 3
The visual structure of the user interface can be defined…
1 point
exclusively in the Java code, by creating objects extending View or ViewGroup.
exclusively in an XML file listing the different Views and ViewGroups
either in the Java code or in an XML file but not in both at the same time for a single “screen”.
in the Java code and/or in an XML file
4.
Question 4
What could be the interest of creating a button (or any other widget) from the Java code of an activity rather than from the associated XML layout file?
1 point
It makes it possible to create the button only if a given condition is fulfilled at runtime.
It requires fewer lines of code.
It makes it possible to associate with the button a text which changes according to the language settings of the device.
5.
Question 5
What could be the interest of creating a button (or any other widget) from an XML layout file rather than from the Java code of an activity?
1 point
It makes the display of the application faster.
The design view allows for a preview of the result without the need to deploy the app on a (real or emulated) device.
It separates the visual design and presentation aspects of the application from its control. Each aspect can even be taking care of by specialized persons.
6.
Question 6
Name the class which represents pop-up messages.
1 point
Enter answer here
7.
Question 7
In addition to the activity or application context, and the message to display, which parameter does the makeText method from the Toast class take?
1 point
the language of the message (Locale.ENGLISH, or Locale.FRENCH…)
the duration of the pop-up (Toast.LENGTH_SHORT or Toast.LENGTH_LONG)
the priority of the message (Toast.URGENT or Toast.NON_URGENT)
the background color of the pop-up (Color.BLUE, Color.BLACK…)
the position of the pop-up (Toast.TOP, Toast.CENTER, or Toast.BOTTOM)
8.
Question 8
Which method from the Toast class allows you to display a pop-up message you’ve prepared?
1 point
bringToForeground()
sendToFront()
display()
show()
9.
Question 9
In an XML layout file you specify that “onClick” a button must call the “doSomething” method. In the activity Java file you create a method “public void doSomething(View v)”. What does the ‘v’ parameter refer to?
1 point
It refers to the graphical preferences set by the user.
It indicates the view which triggered the method call.
It points to the layout onto which the button is positioned.
10.
Question 10
Which method of the Activity class allows you to retrieve a reference to a widget defined in the XML layout file (assuming you know the “name” of the widget)?
1 point
Enter answer here
11.
Question 11
Consider the following code:
Which method must be called at the location indicated with “—–” to turn the background of the button to blue.?
1 point
Enter answer here
12.
Question 12
The following code displays a pop-up message reading “hello” for a short duration:
1
Toast.makeText(getApplicationContext(), “hello”, Toast.LENGTH_SHORT);
1 point
true
false
13.
Question 13
Which of the following code extracts create a button which displays a pop-up message when clicked?
All Options Are Correct
14.
Question 14
For how long (in second) does a Toast displayed for a duration “Toast.LENGTH_SHORT” stays on the screen?
1 point
Enter answer here
block 2
1.
Question 1
To create an application that proposes the user interface in multiple languages the best way is to…
1 point
to request a translation from the Google service for each String to be displayed at runtime.
to use InternationalString objects instead of String objects, example: new InternationalString(new Loc(“Hello”,Loc.EN), new Loc(“Bonjour”,Loc.FR));
copy the existing app and translate the copy. The user will install whichever version he prefers.
to indicate the key of the string to display instead of the value of this string and to define multiple resources files (one per language) where the appropriate, translated value is given for each key.
2.
Question 2
Which folder of your Android Studio project contains the French translation of your application?
1 point
/app/src/main/res/strings-fr
/app/src/main/res/locales
/app/src/main/res/values-fr
/app/src/main/res/translations
3.
Question 3
Your res/values/strings.xml file contains:
12
<string name=”labelA”>Lalala</string>
<string name=”labelB”>Broum</string>
and your res/values-fr/strings.xml file contains:
1
<string name=”labelB”>Bebebe</string>
What happen if the device language is set to French and the interface asks for the “labelA” string?
1 point
As the French version is not complete, everything will be displayed using the default language. The interface will display some “Lalala” and some “Broum”.
Android Studio will detect an error and will refuse to package this app untill the translation is complete.
The French version will be used when available, elsewhere the default version will be used. The interface will display some “Lalala” and some “Bebebe”.
The application will stop (crash) when trying to display the string named labelA.
4.
Question 4
How do you preview your user interface for the various languages you provide translation for?
1 point
It cannot be previewed without a (real or emulated) device: I change the language settings of the device and next I install the app on the device.
It cannot be previewed without a (real or emulated) device: I change the language settings of the device, next I restart the device, and I install the app on the device.
I change the “location” attribute in the AndroidManifest.xml file and next I open the “Design” view of the XML layout file.
I change the “android:locale” attribute of the root layout, and next I switch to the “Design” view to observe the translated version.
In the “Design” view of the XML layout file, a button opens up a menu in which to choose the locale to use.
5.
Question 5
How do you populate a ListView?
1 point
I use the addItem(Sring s) method.
I use the addChild(View v) method.
I use an ArrayAdapter which creates a TextView for each string array item and bind them to the ListView.
6.
Question 6
How can you react to click events on an item of a ListView?
1 point
I create and associate to the ListView an object implementing the AdapterView.OnItemClickListener interface.
In the XML layout file I set the “onClick” property of the ListView to the name of the method to call when an item is clicked.
block 3: layouts
1.
Question 1
A ViewGroup (such as a LinearLayout for instance) allows you to organize the components of the graphical user interface.
Which of the following propositions are true?
1 point
A component may be a ViewGroup it-self, containing other elements.
It is possible to have multiple ViewGroup elements in the description of a single screen as long as they are not nested in each other.
An interface may contain only one ViewGroup element.
2.
Question 2
The following XML code is valid to define a graphical user interface:
1234567891011121314
1 point
false
true
3.
Question 3
Which layout organizes views side by side in its horizontal version?
1 point
GridLayout
LinearLayout
RelativeLayout
4.
Question 4
Which layout allows you to specify the position of a view using other views as references?
1 point
GridLayout
LinearLayout
RelativeLayout
5.
Question 5
For each View or ViewGroup you need to specify the layout_width and layout_height. You can use fixed sizes (in pixels for instance) but which constant can you use to specify that the view should be just large enough for its content (and eventual padding)?
1 point
Enter answer here
6.
Question 6
For each View or ViewGroup you need to specify the layout_width and
layout_height. You can use fixed sizes (in pixels for instance) but
which constant can you use to specify that the view should be as large as the view into which it is included?
1 point
Enter answer here
block 4
1.
Question 1
What audio or video sources can you play in your application?
1 point
multimedia files stored on the file system of the device
multimedia files stored as resources of the application
data streamed from a network connection
2.
Question 2
In which folder must you put the multimedia files which are part of your application?
1 point
Enter answer here
3.
Question 3
Which of the following propositions are valid names for MP3 files placed in the res/raw folder?
1 point
_mymusic
007_mymusic
007
mymusic
mymusic2
myMusic
my-music
my_music
4.
Question 4
Which class can you use to play a music file?
1 point
Enter answer here
5.
Question 5
It’s possible to add music to the output audio flow during a phone call.
1 point
true
false
6.
Question 6
The music files in the application resources folder must be in the raw (“Real Audio Wrapper”) audio file format, i.e. uncompressed and without metadata.
1 point
true
false
7.
Question 7
Which method of the MediaPlayer class allows you to read a music file from a given point in time (rather than from the beginning of the song)?
1 point
Enter answer here
8.
Question 8
Once your application no longer plays music, it’s a good practice to
1 point
call the reset method of the MediaPlayer object
free the associated resources by using the release method from the MediaPlayer class
terminate the current activity (the one which was playing the music)
not destroy the MediaPlayer object in case it might be useful elsewhere in the application
9.
Question 9
If you call the stop method of the MediaPlayer object to turn the music off, calling next the start method will resume the music playing from the beginning of the file.
1 point
true
false
block 5
1.
Question 1
In which folder of the emulator file system do you find the preferences file created by the app named “myGame”?
1 point
com.myuniquename.mygame/data/data/shared_prefs
storage/R.shared_prefs.mygame
data/data/com.myuniquename.mygame/cache
data/data/com.myuniquename.mygame/shared_prefs
2.
Question 2
Which of the following content is a preferences file?
1 point
1234567
<?xml version=’1.0′ encoding=’utf-8′ standalone=’yes’ ?>
<map>
<int name=”age” value=”23″ />
<boolean name=”single” value=”true” />
<int name=”score” value=”42″ />
<string name=”firstname”>Bob</string>
</map>
3.
Question 3
This is the content of the file data/data/com.myuniquename.mygame/shared_prefs/mypref.xml:
1234
<?xml version=’1.0′ encoding=’utf-8′ standalone=’yes’ ?>
<map>
<int name=”age” value=”23″ />
</map>
What will be the content after the execution of the following code:
1234
SharedPreferences preferences = getSharedPreferences(“mypref”,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = preferences.edit();
editor.putInt(“age”, 37);
1 point
The content will be unchanged because there is already a preference labeled “age” in the file.
The content will be unchanged because something is missing from the updating code.
The content will be unchanged because the app will crash executing this code because the “age” key is already present in the file.
1234
<?xml version=’1.0′ encoding=’utf-8′ standalone=’yes’ ?>
<map>
<int name=”age” value=”37″ />
</map>
4.
Question 4
How can you provide exclusive choices?
1 point
I use a set of RadioButtons, I attach an OnCheckedChangeListener to each of them and when a button passes to the isChecked state I call setChecked(false) on all the other buttons.
I use a Switch.
I use a set of RadioButtons embedded in a RadioGroup and I attach an OnCheckedChangeListener to the group.
Week- 4
block 6
1.
Question 1
Which of the following image file requires modification before being placed in the res/drawable folder?
1 point
nice_house.Tiff
desert_3.png
101Dalmatians.jpg
building.svg
2.
Question 2
How do you set the content of an ImageView in your XML layout file?
1 android:src=”@drawable/nicepainting”
3.
Question 3
How do you set the content of an ImageView in your java code?
1 myImageView.setImageResource(R.drawable.nicepainting);
block 7
1.
Question 1
Which component from the palette of the Design view of your XML layout file must you choose to include in your GUI an area able to display a web page?
1 point
The design editor
2.
Question 2
What is the difference between a WebView and a browser?
1 point
A WebView has no “go back” navigation button.
A WebView does not allow you to click on links to other web pages.
a WebView cannot display a page which uses JavaScript.
3.
Question 3
Which method from the WebView class loads a web page?
1 point
Enter answer here
4.
Question 4
What must you remember to do so your WebView can display a page hosted on the Internet?
1 point
Declare that the application needs the permission to access the Internet.
Declare that the activity which includes the WebView needs the permission to access the Internet.
5.
Question 5
In which file do you specify the permissions requested by the application?
1 point
Enter answer here
block 8
1.
Question 1
Which class represents a messaging object that allows you to request actions from other components of the application (for instance: request that another activity be started)?
1 point
Enter answer here
2.
Question 2
Which of the following code extracts from the current activity allows you to launch a new activity?
1 point
123
Intent myIntent = new Intent();
myIntent.setClass(this, AnotherActivity.class);
startActivity(myIntent);
1
setContentView(new AnotherActivity());
3.
Question 3
Which method of the Intent class allows you to pass information to the target?
1 point
Enter answer here
4.
Question 4
The putExtra methods of the Intent class take as second parameter the value or reference to be passed to the target of the intent. What is the first parameter?
1 point
It is a label (or key) for the transmitted value or object.
It is the name of the activity to launch.
It is the type (int, String…) of the transmitted value or object.
block 9
1.
Question 1
Why is the following Intent considered as an “implicit” intent?
123
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setData(Uri.parse(“smsto:5556”));
smsIntent.putExtra(“sms_body”, “hello”);
1 point
Because the destination and the content are not specified at the creation of the Intent but rather are set afterwards.
It is not an implicit intent. Implicit intents are offered by the ImplicitIntent class.
Because it does not specify the name of a particular target component;
rather it declares a general action to perform, which allows a component
from another app to handle it.
2.
Question 2
What happens at the execution of the following code if no app able to handle ACTION_SENDTO is installed on your phone?
12345
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setData(Uri.parse(“smsto:5556”));
smsIntent.putExtra(“sms_body”, “hello”);
startActivity(smsIntent);
toastFailed.show();
1 point
The application will crash.
The startActivity method is not executed and the execution moves to the next instruction.
The user will be prompted to install one.
3.
Question 3
Which action can you use for an implicit intent to open a camera app and receive the resulting photo?
1 point
ACTION_GET_PICTURE
ACTION_CAMERA_SHOT
ACTION_IMAGE_CAPTURE
Life Cycle and Log
1.
Question 1
In which method of an Activity do you usually call the setContentView method?
1 point
onCreate
onStart
onRestart
onResume
onPause
onStop
onDestroy
2.
Question 2
Consider the life cycle of an activity:
To which method does the ‘C’ refer?
1 point
onStop
onResume
onStart
onPause
onRestart
onCreate
onDestroy
3.
Question 3
Which class from the Android API allows you to print debug messages to a dedicated view of Android Studio?
1 point
Enter answer here
4.
Question 4
The Log class allows you to print debug messages to a dedicated view of Android Studio. This class offers the following methods:
1 point
d(…), e(…), i(…) depending whether you want to display a message (‘d’), to raise an exception (‘e’) or to insert a message into the log (‘i’)
print(…) and add(…)
d(…), e(…), i(…) depending on the “status” of the message: debug, error, information.
5.
Question 5
The methods from the Log class usually call for 2 parameters:
1 point
The first parameter indicates the status of the message (error, warning, debug, information), the second parameter is the message to display.
The first parameter is the message to display, the second parameter is a tag which can be used to filter messages.
The first parameter is a tag which can be used to filter messages, the second parameter is the message to display.
6.
Question 6
In which view/window of Android Studio can you examine the messages printed by the Log class?
1 point
debug
error log
logcat
console
7.
Question 7
Which criteria can be used to filter messages printed by the Log class?
1 point
the tag of the message
the text of the message
the priority/level (debug, warning, error, information…)
8.
Question 8
How can you send commands to the emulator?
1 point
I look for the id of the emulator in its upper right corner (usually 5554 for the first instance of the emulator) and I use the ADB tool to connect to it.
I use the AVD manager which was used to create and start the emulator, I select the emulator I want to control from the list of available emulators and I right-click on its line.
I look for the id of the emulator in its upper right corner (usually 5554 for the first instance of the emulator) and I use the telnet program to connect to it.
9.
Question 9
Which command do you send to your emulator via telnet to simulate a fully charged battery? (hint: connect to your emulator and type “help”)
1 point
Enter answer here
10.
Question 10
Which of the following commands are accepted by the emulator?
1 point
shake on
gps status
power display
finger touch
sms send
sensor get
gsm accept
gsm call
Final Quiz
1.
Question 1
This is an extract from an XML layout file:
123456789
<Button
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”click”
android:id=”@+id/myButton”
android:layout_alignParentTop=”true”
android:layout_alignParentLeft=”true”
android:layout_alignParentStart=”true”
android:onClick=”go” />
Which method must be defined in your activity Java code in order to display a pop-up message when this button is clicked?
1 point
public void click(Intent i)
public void click(View v)
public Intent go()
public void go(View v)
public Intent click()
public void go(Intent i)
2.
Question 2
How can you pass several integer values to an activity which you start from your current activity?
1 point
It is impossible.
You use a single call to the putExtra method which accepts an array of integers.
You use successive calls to the putExtra method, providing a different <key, integer value> set at each call.
You can save the integer values in a preferences file in the onStop method of the first activity and read this file in the onCreate method of the second activity.
3.
Question 3
The visual structure of the graphical user interface can be defined…
1 point
in the Java code and/or in an XML file
either in the Java code or in an XML file but not in both at the same time for a single “screen”.
exclusively in the Java code, by creating objects extending View or ViewGroup.
exclusively in an XML file listing the different Views and ViewGroups
4.
Question 4
You provided translations for all Strings in your app in French, Spanish and English. Which language will be used when a user from San Francisco plays with it?
1 point
When installing the app the user is asked to choose a language for the interface.
If available, Android uses GPS positioning to decide on the language to use. So in San Francisco, the app will use English.
Android loads the appropriate version according to the locale settings of the device at run time.
4.
Question 4
What makes it easier to support multiple languages?
1 point
To install Android Studio in multiple languages.
Not to hard-code strings to be displayed in the XML layout files but rather to set all the strings from the Java code.
To keep in separate files the strings displayed by the user interface from the definition of the layouts and the Java code.
Not to hard-code strings to be displayed in the java files but rather to set all the strings from the XML layout files.
5.
Question 5
Find the missing word:
A ______ defines the visual structure for a user interface. It can be declared in an XML file or its elements can be created programmatically and instantiated at runtime.
1 point
Enter answer here
layout |
6.
Question 6
Which method(s) from the MediaPlayer class allows you to adjust the sound level?
1 point
setVolume (float leftVolume, float rightVolume)
increaseVolume(float amount) and decreaseVolume(float amount) (along with getVolume())
setLeftVolume(float volume) and setRightVolume (float volume)
changeSpeakerPower(float percentage)
7.
Question 7
What is the ADB?
1 point
Android Data Base: a data base service included in the Android platform
Android Donut beta: a pre-release version of Android 1.6
Android Device Builder: a tool to create and manage virtual devices.
Android Debug Bridge: a command line tool to communicate with an emulator instance or connected Android-powered device.
8.
Question 8
How are preferences saved to an XML file?
1 point
as a set of ordered <value>
as a set of <key, value>
as a set of <key, type, value>
9.
Question 9
Which method from the ImageView class allows you to adjust the transparency (alpha value) of an image?
1 point
Enter answer here
setAlpha |
10.
Question 10
How do you indicate that your app requires an access to the Internet to display a web page?
1 point
I call the setInternetAccess(true) method on my WebView object.
I add a requests-permission in the AndroidManisfest.xml file.
I add a uses-permission in the AndroidManifest.xml file.
11.
Question 11
Which method of the Intent class allows you to add data to it?
1 point
setData
addData
putExtra
12.
Question 12
Why is the following Intent considered as an “implicit” intent?
123
Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
smsIntent.setData(Uri.parse(“smsto:5556”));
smsIntent.putExtra(“sms_body”, “hello”);
1 point
Because it does not specify the name of a particular target component;
rather it declares a general action to perform, which allows a component
from another app to handle it.
It is not an implicit intent. Implicit intents are offered by the ImplicitIntent class.
Because the destination and the content are not specified at the creation of the Intent but rather are set afterwards.
13.
Question 13
Which method from the Activity class matches the following description:
Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes
to the foreground.
1 point
onStart()
onCreate()
onRestart()
onPause()
onStop()
onDestroy()
14.
Question 14
The Log class proposes a method called “d”. What does it stand for?
1 point
disconnect
debug
display
dump
15.
Question 15
How to direct a SMS to an emulator instance?
1 point
Right-click on the emulator name in the AVD and select “send SMS”.
Telnet to the emulator and issue an “sms send” command.
Send a SMS from another emulator.
Peer-graded Assignment: Code Your Application!
Here I attach 3 alternative answers . You may try one by one