Univenify No. 1 I I I H I H I I I I Seat No. THE UNIVERSITY OF HONG KONG FACULTY OF ENGINEERING DEPARTMENT OF COMPUTER SCIENCE ----- COMP3330 Interactive Mobile Application Design and Programming Date: Dec 18, 2017 Time: 2:30pm-5:30pm Only approved calculators as announced by the Examinations Secretary can be used in this examination. It is the candidates' responsibility to ensure that their calculator operates satisfactorily, and candidates must record the name and type of the calculator used below. Brand name and type of calculator: - ----- - - - - -------- Special Note: Candidates are permitted to bring to the examination ONE sheet of A4-sized paper with printed or written notes on both sides. Answer ALL questions (120 points). Please write all your answers onto the answer sheets provided. Page I of 18 Section A Multiple Choice Ql [2 points] Which of the following regarding smart phone operating systems is/are NOT correct? (i) Android dominates the smart phone market for years. (ii) Blackberry phones can only run Blackberry OS. (iii) Python is the primitive programming language for Symbian apps development. (iv) Windows Phone is the successor of Windows Mobile. (v) One can install an APK file downloaded from an Internet site onto an iPhone. (A) (i) and (iii) only (B) (i) and (iv) only (C) (ii) and (v) only (D) (ii), (iii) and (v) only (E) (ii), (iii), (iv) and (v) only Q2 [2 points] Which of the following Integrated Development Environments (IDEs) CAN be used to develop Android applications? (i) Eclipse (ii) Xcode (iii) Titanium (iv) Unity (v) MIT App Inventor (A)(i) only (B) (ii) only (C) (i) and (iv) only (D)(i), (iv) and (v) only (E) (i), (iii), (iv) and (v) only Page 2of18 Q3 [2 points] Which of the following are NOT names of Android version? (i) Fro yo (ii) Gingerbear (iii) Ice Cream Sandwich (iv) Lollipop (v) Mushroom (A) (i) and (ii) only (B) (ii) and (v) only (C) (iii) and (iv) only (D) (ii), (iii) and (v) only (E) (i), (ii), (iii) and (v) only Q4 [2 points] Which of the following about the user interface design law Magic Number Seven is/are correct? (i) The law comes from a paper written by a cognitive psychologist George Mitcheson. (ii) The number of objects an average human can process at any time is 7 ± 2. (iii) A designer needs 7 ± 2 days on average to design the user interface. (iv) The number of each kind of user interface component should be multiple of 7. (v) The design of any user interface has to be reviewed by at least 7 other people. (A)(i) only (B) (ii) only (C) (iii) only (D)(i) and (iii) only (E) (iv) and (v) only Page 3of18 QS [2 points] Which of the following is/are contained within the Android Manifest? (i) Pennissions the application requires (ii) List of strings used in the application (iii) List of activities in the application (iv) User interface layout definition (v) Developer's infonnation (A)(i) only (B) (i) and (ii) only (C) (i) and (iii) only (D) (ii) and (iv) only (E) (ii), (iii) and (v) only Q6 [2 points] Which layout has been deprecated and which layout is the latest addition to Android's collection of layouts? (i) AbsoluteLayout (ii) FrameLayout (iii) LinearLayout (iv) RelativeLayout (v) ConstraintLayout (A) (i) has been deprecated and (iv) is the latest addition. (B) (i) has been deprecated and (v) is the latest addition. (C) (ii) has been deprecated and (iv) is the latest addition. (D) (ii) has been deprecated and (v) is the latest addition. (E) (iii) has been deprecated and ( v) is the latest addition Page 4of18 Q7 [2 points] What should be the correct order of the following statements for describing AbsoluteLayout, FrameLayout, LinearLayout, TableLayout and RelativeLayout, respectively? (i) Elements are organized along a single line. (ii) You have to lay out elements based on their relationships with one another, and with the parent container. (iii) Multiple elements will be displayed overlapping. (iv) You just need to define rows in the layout XML, while the columns are determined automatically. (v) You have to specify the exact x and y coordinates of each component. (A) (i), (ii), (iii), (iv), (v) (B) (i), (iii), (v), (ii), (iv) (C) (iii), (iv), (v), (i), (ii) (D) (v), (iii), (i), (iv), (ii) (E) (v), (iv), (iii), (ii), (i) Q8 [2 points] Which of the following is a correct sequence of method execution in an Activity life cycle? (A)onCreate () -7 onStart () -7 onResume () (B) onCreate () -7 onResume () -7 onStart () (C) onStart () -7 onCreate () -7 onResume () (D)onStart () -7 onResume () -7 onCreate () (E) onResume () -7 onStart () -7 onCreate () Q9 [2 points) When activity X triggers another activity Y to be on top of X so that X is no longer visible, which of the followings will be called for X? (A)onStop () (B) onPause () (C) onDestroy () (D) onSleep () (E) onLeave () Page 5of18 QlO [2 points] Which of the following can be included in an Intent object? (i) Component name (ii) Action (iii) Category (iv) Extra (v) Flags (A) (i) and (ii) (B) (i) and (iii) (C) (i), (ii) and (iii) (D) (i), (iii) and (iv) (E) (i), (ii), (iii), (iv) and (v) Qll [2 points] Order the following in descending order of importance. (i) Visible process (ii) Background process (iii) Empty process (iv) Service process (v) Foreground process (A)(i), (v), (ii), (iv), (iii) (B) (i), (v), (iv), (ii), (iii) (C) (iii), (v), (i), (iv), (ii) (D) (v), (i), (iv), (ii), (iii) (E) (v), (iv), (i), (ii), (iii) Page 6of18 Q12 [2 points] Which of the following is NOT an external storage public directory? (i) DIRECTORY _DCIM (ii) DIRECTORY DOCUMENTS (iii) DIRECTORY MOVIES (iv) DIRECTORY PODCASTS (v) DIRECTORY NOTIFICATIONS (A)(i) only (B) (iii) only (C) (ii) and (iii) only (D) (iv) and (v) only (E) None of the above Q13 [2 points] Which of the following are parameters of the play () method of soundPool? (i) Left I right volume (ii) Priority (iii) Sound quality (iv) Playback rate (v) Maximum number of streams that can be played at the same time (A) (i) and (ii) only (B) (i), (ii) and (iv) only (C) (ii) and (iv) only (D) (ii), (iii) and (iv) only (E) (i), (ii), (iii), (iv) and (v) Page 7of18 Q14 [2 points] Which of the following are properties that can be returned by the getLayoutParams () method of Rel a ti veLayout. LayoutParams? (i) leftMargin (ii) topMargin (iii) height (iv) weight (v) gravity (A) (i), (ii) and (iii) only (B) (i), (ii) and (iv) only (C) (ii), (iii) and (iv) only (D)(ii), (iv) and (v) only (E) (iii), (iv) and (v) only Q15 [2 points] Suppose SQLi teDatabase db= getWri tableDatabase ().Which of the following operation is/are NOT valid? (i) db. insert ( ... ) (ii) db.delete( ... ) (iii) db.update ( ... ) (iv) db. executeSQL ( ... ) (v) db. create ( ... ) (A) (i) and (ii) only (B) (ii) and (iii) only (C) (iv) and (v) only (D) (i), (iii) and (iv) only (E) (iii), (iv) and (v) only Page 8of18 Section B Long Questions Ql [10 points] (a) According to statistics, game is the most popular category in the smart phone application market. State TWO examples (2 points) and write down TWO features that applications under this category should possess (2 points). (b) Open Crowdsourcing and Sharing Economy are considered to be two new categories of smart phone applications. Explain what they are ( 4 points) and state ONE example for each of them (2 points). Q2 [10 points] A developer has written a simple Android application for calculating the download time (in sec) given the download rate (in Mbits I sec) and file size (in Mbytes) as follows: 2.4 100 fif1~ $11~ (Ml"',-l:>~I ~--- CALCULATE CALCULATE The user just needs to enter information into the two EditText fields and press the "CALCULATE" button, the result will be displayed accordingly. The layout file activity_ main.xml contains the following: xmlns:tools= "http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="rnatch_parent" tools:context="hkucs . test3.MainActivity"> android:text="Download Rate (Mbits I sec):" android:layout_width="wrap_content " Page 9of18 android:layout_height="wrap content" /> android:id="@+id/download_rate" android:width="500px" android:layout_width="wrap_content" android:layout_height="wrap_content" /> android: text="File Size (Mbytes): 11 android:layout_width="wrap_content" android:layout_height="wrap_content" /> android:id="@+id/file_size" android:width="500px" android:layout_width="wrap content" android:layout_height="wrap content" /> The mam program MainActivity.java is partially completed as follows. Please fill in the missing blanks to complete the program (I point each). package hkucs.downloadtime; import android.support.v7.app.AppCompatActivity; import android.as.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; Page 10of18 public class MainActivi ty extends EditText dRate, fSize; Button cButton; TextView dTime; @Override protected void onCreate(Bundle savedinstanceState) super.onCreate(savedinstanceState); setContentView(R.layout. (ii) _____ ); dRate (Edi tText) (iii) fSize (EditText) (iv) dTime (TextView) (v) cButton = (Button) (vi) cButton.setOnCli ckListener(new --~~-(vii) ___ ~~ } ) ; ---~- ( viii)_~-~- public void onClick(View v) String dRateString String fSizeString double Result = ---~~-(ix)~-~~~- _____ (x) __ ~~- dTime . setTe xt( " Download Time= " + String.valueOf(Result) + " sec"); Q3 [10 points] Please draw the following layout onto the answer sheet. xmlns:android="http://schemas .android.com/apk/re s/android" xmlns:app="http://schemas.android . com/apk/res- auto" xmlns:tools="http:/ /schemas.android.com/tools" android:layout_width="match_parent" android:layout_ height="matc h_paren t " tools:layout_editor_absolut e Y="Odp" Page 11 of18 tools:layout_editor_absoluteX="Odp"> android:id="@+id/textViewl" android:layout_width="wrap content" android:layout_height="wrap_content" android:text="COMP3330" android:textSize=''30sp'' app:layout_constraintLeft toLeftOf="parent" app:layout constraintTop_toTopOf="parent" android:layout_marginTop="50dp" /> android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Examination" android:textSize=''30sp'' app:layout_constraintRight_toRightOf="parent 11 android:layout_marginRight="60dp" app:layout_constraintTop_toTopOf="parent" android: layout __ marginTop="l50dp" app:layout constraintLeft toRightOf="@id/textViewl" />