Coursera Answers

Programming Mobile Applications for Android Handheld Systems: Part 1 | Week 2 Quiz Answer

Programming Mobile Applications for Android Handheld Systems Part 1  Week 2 Quiz Answer

Programming Mobile Applications for Android Handheld Systems: Part 1 | Week 2 Quiz Answer

In This Article i am gone to Share Programming Mobile Applications for Android Handheld Systems: Part 1 | Week 2 | Practice Exercise: Application Fundamentals and the Activity Class Quiz Answer with you..



Week -2 
Practice Exercise Quiz Answer

Application Fundamentals and the Activity Class 


Question 1)
Which two of the following statements capture the main purposes of the Service class?
  • To provide an application’s user interface.
  • To enable remote (inter-process) operations.
  • To support long-running, in the background operations.
  • To manage concurrent access to shared databases.


Question 2)
Ignoring the initial xml declaration, what is the outermost xml tag used in the AndroidManifest.xml file?
  • manifest


Question 3)
How would you specify a string called “exit_message” whose value is “Goodbye”, within a strings.xml file?

  • <value android:id=”string_name”>text_string</value>
  • <string> “Goodbye” </string>
  • <string name=”string_name”>text_string</string>
  • <string name=”exit_message”>Goodbye</string>


Question 4)
(True or False) One of the main jobs of the Activity class is to support concurrent access to shared, inter-application data.

  • True
  • False


Question 5)
The example applications for this lecture contain Activities that call setContentView(), passing in a resource ID. Which one of the following statements correctly reflects what the setContentView() method does?

  • It validates the data type of the resource ID.
  • It attaches button listeners to the code.
  • It inserts a package in the PackageManger’s database.
  • It processes the underlying resource file to create Java Objects corresponding to the elements specified in the resource file.


Explanation:
The process of creating Java Objects corresponding to a resource is called inflating.


Question 6)
Suppose that your application has brought Activity A into the foreground. The user then presses a button shown by Activity A, which causes Activity B to be brought into the foreground, ready for user interaction. At this point, what was most likely the last lifecycle method called on Activity A and on Activity B?

  • ActivityA.onStop() and ActivityB.onResume().
  • ActivityA.onResume() and ActivityB.onDestroy().
  • ActivityA.onDestroy() and ActivityB.onCreate().
  • ActivityA.onPause() and ActivityB.onRestart()


Question 7)
Suppose you write an Activity that edits some persistent user information such as the user’s account name, but does not save it immediately. This important data must be saved before the application exits. In which lifecycle method should you normally save the data?

  • onStop().
  • onPause().
  • onResume().
  • onDestroy().


Explanation:
Remember that onStop() and onDestroy() may not always be called.


Question 8)
Suppose you attach an OnClickListener to a Button in your Activity. When will this Object’s onClick() method be called?

  • When the user hits the Back Key.
  • When the user presses and holds the Button.
  • When the user hits the Home Key.
  • When the user presses and releases the Button in quicksuccession .


Question 9)
One example of a configuration change, is when the user changes the device’s global font size. If you want to handle this configuration change manually, what value would you add to a android:configChanges attribute in the application’s AndroidManifest.xml file? See: http://developer.android.com/guide/topics/manifest/activity-element.html for more information.


  • fontScale

Question 10)
Unless you have a strong reason for doing so, you should generally avoid handling configuration changes manually. Which one of the following statements best explains why?

  • It always takes more time to handle configuration changes manually.
  • It can be difficult to know and capture each configuration
  • change that might occur.
  • Configuration changes are not thread safe.
  • System reconfiguration can be checked for correctness at compile time.


Explanation:
Despite this difficulty, you may still sometimes decide to handle configuration changes manually. For example, when your application doesn’t need to update resources during a particular configuration change and when your application’s performance would suffer from an activity restart.