IT 372 - Quizzes * = correct answer Quiz questions and answers will be posted after each quiz closes. ----------------------------------------------------- Quiz 1. Closed Apr 14. 1. If the package name of an Android Studio project is it372.proj1, where is the Java file MainActivity.java located? a. app/main/src/java b. app/main/src/java/it372/Proj1 c. app/src/main/java *d. app/src/main/java/it372/Proj1 2. Where is the layout file activity_main.xml located within the app folder of an Android app? a. app/main/src/res/values/layout *b. app/src/main/res/layout c. app/src/main/res/values/layout d. app/src/main/java/layout 3. What is the current version of Android Studio? a. Bumblebee b. Electric Eel *c. Iguana d. Hedgehog 4. Which tool in Android Studio is used to download and install virtual device drivers? The ____________ Manager. a. Activity b. Device c. SDK d. Resource 5. Which attribute do you add to the TextView element in the layout file to set the font color to maroon? a. android:font-color="#0080FF" b. android:fontColor="#800000" c. android:text-color="#0080FF" *d. android:textColor="#800000" ----------------------------------------------------- Quiz 2. Closed Apr 21. 1. Which Android MainActivity method is roughly equivalent to the main method of a traditional Java class? a. MainActivity *b. onCreate b. onStartUp d. startUp 2. Which statement in MainActivity.java sets the layout as activity_main.xml for the app? *a. setContentView(R.layout.activity_main); b. setContentView(R.layout.main); c. setLayout(R.layout.activity_main); d. setLayout(R.layout.main); 3. Which attribute correctly defines the id of a TextView widget as txt_age? a. android:id="+id/txt_age" b. android:id="@id/txt_age" c. android:id="@+id/txt_age" *d. android:id="age" 4. Which statement defines the XML namespace prefix android? a. android="https://schemas.android.com/apk/res/android" b. android:xmlns="https://schemas.android.com/apk/res/android" c. namespace:android="https://schemas.android.com/apk/res/android" d. xmlns:android="https://schemas.android.com/apk/res/android" 5. In the strings.xml resource file, how do you define a string with the name "pred1" and the value "It is certain."? a. "It is certain." *b. It is certain. c. d. ----------------------------------------------------- Quiz 3. Closed Apr 28. 1. A widget of which class allows the user to enter text into the widget. *a. EditText b. EditView c. TextField d. TextView 2. If w1 is a CheckBox or RadioButton widget, which method call returns true if the widget is checked. a. chk1.checked *b. chk1.isChecked( ) b. chk1.isChecked(true); d. chk1.getChecked(true); 3. The Elvis operator (also known as the tertiary conditional operator) consists of which two symbols? a. ? = b. ? > *c. ? : d. < ? 4. From the ArrayList collection dice, which statement obtains the value with index 1? a. int item = col[1]; *b. int item = col.get(1); b. int item = col.get[1]; d. int item = col.getItem[1]; 5. Which method is required in an Android Activity class? *a. onCreate b. onDestroy c. onResume d. onStart ----------------------------------------------------- Quiz 4. Closed May 5. 1. Which of the following MainActivity.java statements changes the background color of the ImageView with id img_color to silver? The ImageView widget is defined like this: ImageView imgColor = findViewById(R.id.img_color); a. layout1.setBackgroundColor(0xFFC0C0C0); b. layout1.setBackgroundColor(Color.silver); c. layout1.setBackgroundColor(Color.parseColor("#FFC0C0C0"); d. layout1.setBackgroundColor(R.color.silver); 2. What is the first event that occurs in the Activity life cycle when an app is launched? *a. ON_CREATE b. ON_PAUSE c. ON_RESUME d. ON_START 3. Which event occurs when the app is moved into the background? a. ON_CREATE *b. ON_PAUSE c. ON_RESUME d. ON_SET_BACKGROUND 4. Which View method can be used to attach a View.OnLongClickListener object or a lambda method to a widget? a. addEventListener b. attachClickListener c. onLongClick *d. setOnLongClickListener 5. An object from which class is used to save data from an activity before it is destroyed so that it can be restored when the activity is recreated, for example, when the device is rotated? a. Adapter *b. Bundle c. HashMap d. Intent ----------------------------------------------------- Quiz 5. Closed May 12. 1. An object from which class is used to create and start a new activity? a. Bundle b. HashMap *c. Intent d. StartActivity 2. Which Java class has an append method? a. ArrayList b. Integer c. String *d. StringBuilder 3. Which ActivityMain.java statement changes the background color of the linear layout to blue? The layout object is obtained like this: LinearLayout layout1 = findViewById(R.id.main); a. layout1.setBackgroundColor(0xFF0000FF); b. layout1.setBackgroundColor(Color.blue); c. layout1.setBackgroundColor(Color.parseColor("#FF0000FF")); d. layout1.setBackgroundColor(R.color.blue); 4. The Design Editor is used with a ConstraintLayout to position a Button widget below a TextView widget with id txt_name. What does this constraint look like in the XML layout file? a. android.layout_constraint="@+id/txt_name" b. android.layout_constraintTop_toBottomOf="@+id/txt_name" *c. app.layout_constraintTop_toBottomOf="@+id/txt_name" d. app.layout_margin="@+id/txt_name" 5. These Java statements add a click event listener to a CheckBox widget using Method 3 (anonymous class). checkbox1.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener( ) { @Override public void onCheckedChanged( CompoundButton compoundButton, boolean b) { Toast t = Toast.makeText(getApplicationContext( ), "Checkbox is " + (compoundButton.isChecked( ) ? "checked" : "unchecked"), Toast.LENGTH_LONG); t.show( ); } }); Which method call adds a CheckedChanged eventlistener using Method 4 (lambda function)? // a. checkbox1.setOnCheckedChangeListener( checkbox1, b -> { Toast t = Toast.makeText(getApplicationContext( ), "Checkbox is " + (compoundButton.isChecked( ) ? "checked" : "unchecked"), Toast.LENGTH_LONG); t.show( ); }); // b. checkbox1.setOnCheckedChangeListener( (checkbox1, b) -> { Toast t = Toast.makeText(getApplicationContext( ), "Checkbox is " + (compoundButton.isChecked( ) ? "checked" : "unchecked"), Toast.LENGTH_LONG); t.show( ); }); // c. checkbox1.setOnCheckedChangeListener( compoundButton, b -> { Toast t = Toast.makeText(getApplicationContext( ), "Checkbox is " + (b ? "checked" : "unchecked"), Toast.LENGTH_LONG); t.show( ); }); // *d. checkbox1.setOnCheckedChangeListener( (cb, b) -> { Toast t = Toast.makeText(getApplicationContext( ), "Checkbox is " + (b ? "checked" : "unchecked"), Toast.LENGTH_LONG); t.show( ); }); Save Time ----------------------------------------------------- Quiz 6. Closed May 19. 1. Find the UTF-8 encoding for the á character (a with acute accent), which has the hex Unicode code E1. This UTF-8 encoding requires two bytes. a. 00E1 b. 03AE *c. C3A1 d. C3E1 2. Find the UTF-8 encoding for the ♯ character (sharp sign from music), which has the hex Unicode code 266F. This UTF-8 encoding requires three bytes. a. 00266F b. C2266F c. C2D9A7 *d. E299AF 3. For an Android drawing in a view, an object of which class is used to specify the color and stroke width for drawing an item? a. Color b. Graphics *c. Paint d. StrokeWidth 4. The class MyView is a derived class of View. Which method of the View class is overridden to contain the code for drawing in a MyView object? a. draw *b. onDraw c. onPaint d. paint 5. What is the file extension of an Android executable file? a. .class *b. .dex c. .java d. .kt ----------------------------------------------------- Quiz 7. Closed May 26. 1. An object of which class is used to call drawing methods in a View onDraw method? *a. Canvas b. Graphics c. Panel d. View 2. An object of which class contains information about a touch event that occurred, which was detected by a touch event handler? For example, this object contains the x and y location of the touch and whether the touch was touch down, touch up, or touch move. a. ClickEvent *b. MotionEvent c. MouseMoveEvent d. TouchEvent 3. To read from a text file named points.txt in the folder app/src/main/res/raw, an object from which class is used? a. File b. FileStream *c. InputStream d. String 4. What is the file extension of an Android app packaged for distribution? *a .apk b. .dex c. .jar d. .pak 5. Which Android Studio tool is used to view folders and files on a Virtual Device? a. Chrome Browser *b. Device File Explorer c. Logcat Window d. Windows File Explorer ----------------------------------------------------- Quiz 8. Closed June 2. 1. If dbh is an object of a class derived from the base class SQLiteOpenHelper, which method call returns an SQLiteDatabase object representing a database that can be modified? a. dbh.getDatabase( ); b. dbh.getDatabase(true); c. dbh.getDb( ) ; *d. dbh.getWritableDatabase( ); 2. In an Android app, an object of which class contains data to be inserted as an SQLite table row. *a. ContentValues b. Point c. RowValues d. TableRow 3. An object of which class contains the results of a query of an SQLite table? *a. Cursor b. QueryResult c. ResultSet d. TableQuery 4. Which Kotlin statement is a translation of this Java statement? int count = 359; a. count = 359; *b. var count = 359 c. var count: int = 359 d. var count = new Int(359) 5. What is the header of a Kotlin toString method? *a. override fun toString( ) : String { b. @Override fun toString( ) : String { c. Override fun toString( ) : str { d. @Override String : toString( ----------------------------------------------------- Quiz 8. Closed June 11. 1. Which keyword is used to create a Kotlin function or method? a. def *b. fun c. function d. No specific keyword is used. 2. Which keyword or token denotes that a Kotlin class is inheriting from a base class? *a. : b. -> c. extends d. inherits 3. Which keyword or token is used in a Kotlin method to indicate that the method overrides a method from an interface. *a. : b. @Override c. override d. Overrides 4. Which keyword or token indicates that a Kotlin derived class is available to be used as a base class. a. : b. :: c. inheritable *d.open 5. In a Jetpack Compose app, the MainActivity class does not inherit from AppCompatActivity, it inherits from _____________ . a. Activity b. Any c. CompatActivity *d. ComponentActivity ------------------------------------------------------