Book Appointment Now

Build Your First Android App (Project-Centered Course) Quiz Answers

Get Build Your First Android App (Project-Centered Course) Quiz Answers

Week 01 Quiz Answers

Quiz about Activities and GUI

Q1. What is a view?

  • It is a structure that organizes the position of the different buttons, texts, and images of the graphical 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.
  • It is a graphical element that can be used in the user interface of your application.

Q2. Is it possible to use multiple views on a single screen of the graphical user interface of your application?

  • Yes
  • No

Q4. Is it possible to nest a layout within another one?

  • no
  • yes

Q5. Android buttons have a predefined style. The size and color of a button and its text cannot be changed.

  • true
  • false

Q6. Associating a name (unique id) to a view is mandatory when using what kind of layout?

  • a vertical linear layout
  • a horizontal linear layout
  • a relative layout

Q7. Which actions can be triggered by a button click? (check all that apply)

  • change the appearance of other views of the same activity
  • start a different activity
  • change the appearance of the button

Q8. When an activity A starts an activity B (check all that apply):

  • the activity B comes to the foreground
  • the activity A is paused or stopped
  • 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

Q9. Activities are completely independent from one another, they cannot share data.

  • false
  • true

Quiz about Application Design

Q1. Which of these propositions describes a mockup?

  • low fidelity
  • middle to high fidelity, dynamic
  • high fidelity but static

Q2. Compared to mockups and prototypes, the amount of time necessary to create wireframes is

  • low
  • medium
  • high

Q3. Which usage or development phase are the mockups most adapted to?

  • gathering feedback and “selling” the visual side
  • user testing, sometimes the production of reusable backbone
  • documentation, earliest iterations

Q4. What is the main characteristic of a wireframe?

  • static visualization of the final look
  • sketchy, black-grey-white representation of the interface
  • clickable

Q5. This application design seems flawed. Why?

  • The application starts with “Screen1” but there is no path to “Screen3”.
  • The vertical LinearLayout in Screen 2 includes a horizontal LinearLayout in its 3rd row.
  • The “Visualize” button does nothing.

Q6. What should you try to keep to a minimum when designing a mobile app?

  • The amount of information passed from one activity to another.
  • The amount of data to be typed in by the user using the soft keyboard.
  • The number of activities.
  • The number of buttons that call a given method.

Week 02 Quiz Answers

Basic Knowledge of Android

Q1. Android Studio is:

  • A tool that allows to dump the memory of a smartphone.
  • A tool that allows to build and test Android applications.
  • A tool that allows to copy large files on a smartphone.

Q2. The AndroidManifest.xml file is a file that contains:

  • The properties of the application
  • The variable and the methods of an activity
  • The resources of the application

Q3. What is the purpose of the Android Virtual Device (AVD)?

  • Modify the user interface of an application
  • Run and test Android application on an emulator
  • Edit and compile Android applications

Q4. Before running an Android application on a Virtual device, you must connect your smartphone to your PC.

  • True
  • False

Q5. 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.

  • False
  • True

Q6. Give the name of the 2 most basic activity templates we use in general to build a basic Android application.

  • Login Activity
  • Full-screen Activity
  • Scrolling Activity
  • Blank Activity
  • Google Maps Activity
  • Empty Activity

Create an interactive application

Q1. In the source code of an application, what function does it used to get a reference to a component of the user interface?

  • findViewById()
  • setOnClickListener()
  • OnClick()

Q2. When an application is compiled a class named R is created. What does it contains ?

  • 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

Q3. The id property of a component can’t be modified ?

  • True
  • False

Week 03 Quiz Answers

block 1

Q1. Which folder of your Android Studio project holds the XML files that describe the graphical interfaces of the MyApp application?

  • MyApp/app/gui
  • MyApp/app/manifests
  • MyApp/app/java
  • MyApp/app/res/layout
  • MyApp/app/values
  • MyApp/app/res/drawable

Q2. 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?

  • 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 call the onStart method and I provide “R.id.myUI” as parameter.
  • 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”.
  • 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 use “myUI.display();”

Q3. The visual structure of the user interface can be defined…

  • 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

Q4. 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?

  • It makes it possible to create the button only if a given condition is fulfilled at runtime.
  • It makes it possible to associate with the button a text which changes according to the language settings of the device.
  • It requires fewer lines of code.

Q5. 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?

  • 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.
  • It makes the display of the application faster.

Q6. Name the class which represents pop-up messages.

Answer: Toast

Q7. In addition to the activity or application context, and the message to display, which parameter does the makeText method from the Toast class take?

  • the priority of the message (Toast.URGENT or Toast.NON_URGENT)
  • the duration of the pop-up (Toast.LENGTH_SHORT or Toast.LENGTH_LONG)
  • the position of the pop-up (Toast.TOP, Toast.CENTER, or Toast.BOTTOM)
  • the background color of the pop-up (Color.BLUE, Color.BLACK…)
  • the language of the message (Locale.ENGLISH, or Locale.FRENCH…)

Q8. Which method from the Toast class allows you to display a pop-up message you’ve prepared?

  • show()
  • bringToForeground()
  • sendToFront()
  • display()

Q9. 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?

  • It points to the layout onto which the button is positioned.
  • It refers to the graphical preferences set by the user.
  • It indicates the view which triggered the method call.

Q10. 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)

Answers: findViewById()

Q11. Consider the following code:

package fr.centralesupelec.galtier.tempo;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button myButton = (Button)findViewById(R.id.myBbutton);
        myButton.-------------(Color.BLUE);
    }
}

Q12. The following code displays a pop-up message reading “hello” for a short duration:

Toast.makeText(getApplicationContext(), "hello", Toast.LENGTH_SHORT);
  • true
  • false

Q13. Which of the following code extracts create a button which displays a pop-up message when clicked?

  • .correct
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button myButton = 
                 new Button(getApplicationContext());
        myButton.setText("click me!");
        myButton.setOnClickListener(
             new View.OnClickListener() {
                public void onClick(View v) {
                   Toast.makeText(getApplicationContext(),
                                  "clicked!",
                                  Toast.LENGTH_SHORT).show();
                }
             });
        RelativeLayout layout = (RelativeLayout) 
                              findViewById(R.id.myLayout);
        layout.addView(myButton);
    }
}
  • .correct
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button myButton = 
                 new Button(getApplicationContext());
        myButton.setText("click me!");
        myButton.setOnClickListener(
             new View.OnClickListener() {
                public void onClick(View v) {
                   Toast.makeText(getApplicationContext(),
                                  "clicked!",
                                  Toast.LENGTH_SHORT).show();
                }
             });
        RelativeLayout layout = (RelativeLayout) 
                              findViewById(R.id.myLayout);
        layout.addView(myButton);
    }
}
  • .correct
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button myButton = 
                 new Button(getApplicationContext());
        myButton.setText("click me!");
        myButton.setOnClickListener(
             new View.OnClickListener() {
                public void onClick(View v) {
                   Toast.makeText(getApplicationContext(),
                                  "clicked!",
                                  Toast.LENGTH_SHORT).show();
                }
             });
        RelativeLayout layout = (RelativeLayout) 
                              findViewById(R.id.myLayout);
        layout.addView(myButton);
    }
}
  • .correct
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button myButton = 
                 new Button(getApplicationContext());
        myButton.setText("click me!");
        myButton.setOnClickListener(
             new View.OnClickListener() {
                public void onClick(View v) {
                   Toast.makeText(getApplicationContext(),
                                  "clicked!",
                                  Toast.LENGTH_SHORT).show();
                }
             });
        RelativeLayout layout = (RelativeLayout) 
                              findViewById(R.id.myLayout);
        layout.addView(myButton);
    }
}

Q14. For how long (in second) does a Toast displayed for a duration “Toast.LENGTH_SHORT” stays on the screen?

block 2

Q1. To create an application that proposes the user interface in multiple languages the best way is to…

  • to use InternationalString objects instead of String objects, example: new InternationalString(new Loc(“Hello”,Loc.EN), new Loc(“Bonjour”,Loc.FR));
  • 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.
  • copy the existing app and translate the copy. The user will install whichever version he prefers.
  • to request a translation from the Google service for each String to be displayed at runtime.

Q2. Which folder of your Android Studio project contains the French translation of your application?

  • /app/src/main/res/strings-fr
  • /app/src/main/res/values-fr
  • /app/src/main/res/translations
  • /app/src/main/res/locales

Q3. Your res/values/strings.xml file contains:

<string name="labelA">Lalala</string>
<string name="labelB">Broum</string>

and your res/values-fr/strings.xml file contains:

<string name="labelB">Bebebe</string>

What happen if the device language is set to French and the interface asks for the “labelA” string?

  • 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.

Q4. How do you preview your user interface for the various languages you provide translation for?

  • I change the “android:locale” attribute of the root layout, and next I switch to the “Design” view to observe the translated version.
  • 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.
  • 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.
  • In the “Design” view of the XML layout file, a button opens up a menu in which to choose the locale to use.

Q5. How do you populate a ListView?

  • 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.

Q6. How can you react to click events on an item of a ListView?

  • 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

Q1. 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?

  • 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.

Q2. The following XML code is valid to define a graphical user interface:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical" >
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hello, I am a TextView" />
</LinearLayout>
<Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello, I am a Button" />
  • false
  • true

Q3. Which layout organizes views side by side in its horizontal version?

  • GridLayout
  • LinearLayout
  • RelativeLayout

Q4. Which layout allows you to specify the position of a view using other views as references?

  • GridLayout
  • LinearLayout
  • RelativeLayout

Q5. 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)?

Q6. 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?

block 4

Q1. What audio or video sources can you play in your application?

  • data streamed from a network connection
  • multimedia files stored as resources of the application
  • multimedia files stored on the file system of the device

Q2.In which folder must you put the multimedia files which are part of your application?

Q3. Which of the following propositions are valid names for MP3 files placed in the res/raw folder?

  • mymusic
  • 007
  • my-music
  • 007_mymusic
  • my_music
  • mymusic2
  • myMusic
  • _mymusic

Q4. Which class can you use to play a music file?

Q5. It’s possible to add music to the output audio flow during a phone call.

  • true
  • false

Q6. 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.

  • true
  • false

Q7. 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)?

Q8. Once your application no longer plays music, it’s a good practice to

  • terminate the current activity (the one which was playing the music)
  • free the associated resources by using the release method from the MediaPlayer class
  • call the reset method of the MediaPlayer object
  • not destroy the MediaPlayer object in case it might be useful elsewhere in the application

Q9. 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.

  • true
  • false

block 5

Q1. In which folder of the emulator file system do you find the preferences file created by the app named “myGame”?

  • data/data/com.myuniquename.mygame/shared_prefs
  • storage/R.shared_prefs.mygame
  • com.myuniquename.mygame/data/data/shared_prefs
  • data/data/com.myuniquename.mygame/cache

Q2. This is the content of the file data/data/com.myuniquename.mygame/shared_prefs/mypref.xml:

<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<map>
<int name="age" value="23" />
</map>
  • The content will be unchanged because the app will crash executing this code because the “age” key is already present in the file.
  • The content will be unchanged because something is missing from the updating code.
  • The content will be unchanged because there is already a preference labeled “age” in the file.

Q3. How can you provide exclusive choices?

  • I use a set of RadioButtons embedded in a RadioGroup and I attach an OnCheckedChangeListener to the group.
  • I use a Switch.
  • 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.

Week 04 Quiz Answers

block 6

Q1. Which of the following image file requires modification before being placed in the res/drawable folder?

  • 101Dalmatians.jpg
  • desert_3.png
  • building.svg
  • nice_house.Tiff

block 7

Q1. 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?

Q2. What is the difference between a WebView and a browser?

  • A WebView has no “go back” navigation button.
  • a WebView cannot display a page which uses JavaScript.
  • A WebView does not allow you to click on links to other web pages.

Q3. Which method from the WebView class loads a web page?

Q4. What must you remember to do so your WebView can display a page hosted on the Internet?

  • 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.

Q5. In which file do you specify the permissions requested by the application?

block 8

Q1. 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)?

Q2. Which method of the Intent class allows you to pass information to the target?

Q3. 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?

  • 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.

Life Cycle and Log

Q1. In which method of an Activity do you usually call the setContentView method?

  • onCreate
  • onStart
  • onRestart
  • onResume
  • onPause
  • onStop
  • onDestroy

Q2. Consider the life cycle of an activity:

Build Your First Android App (Project-Centered Course) Quiz Answers

To which method does the ‘A’ refer

  • onRestart
  • onPause
  • onCreate
  • onDestroy
  • onStart
  • onResume
  • onStop

Q3. Which class from the Android API allows you to print debug messages to a dedicated view of Android Studio?

Q4. The Log class allows you to print debug messages to a dedicated view of Android Studio. This class offers the following methods:

  • print(…) and add(…)
  • 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’)
  • d(…), e(…), i(…) depending on the “status” of the message: debug, error, information.

Q5. The methods from the Log class usually call for 2 parameters:

  • 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.

Q6. In which view/window of Android Studio can you examine the messages printed by the Log class?

  • logcat
  • error log
  • console
  • debug

Q7. Which criteria can be used to filter messages printed by the Log class?

  • the tag of the message
  • the text of the message
  • the priority/level (debug, warning, error, information…)

Q8. How can you send commands to the emulator?

  • 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.
  • 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.

Q9. Which command do you send to your emulator via telnet to simulate a fully charged battery? (hint: connect to your emulator and type “help”)

Q10. Which of the following commands are accepted by the emulator?

  • finger touch
  • sensor get
  • gsm call
  • gps status
  • gsm accept
  • shake on
  • power display
  • sms send

Get All Course Quiz Answers of Software Development Lifecycle Specialization

Software Development Processes and Methodologies Quiz Answers

Agile Software Development Coursera Quiz Answers

Lean Software Development Coursera Quiz Answers

Engineering Practices for Building Quality Software Quiz Answers

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *