MCQs / Computer Science / Lab: Registration Form UI

Lab: Registration Form UI MCQs — Computer Science

15 multiple-choice questions on Lab: Registration Form UI from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.

1. Why is the form wrapped in a ScrollView?

  1. So all fields remain reachable in landscape or when the keyboard is open
  2. To validate input
  3. To lock orientation
  4. To make text bold

Answer: A) So all fields remain reachable in landscape or when the keyboard is open

Explanation: ScrollView lets long content scroll.

Discuss this question

2. Which code reads the text typed in an EditText named etName (Kotlin)?

  1. etName.input()
  2. etName.hint
  3. etName.text.toString()
  4. etName.getValue()

Answer: C) etName.text.toString()

Explanation: text returns an Editable; toString() converts it to a String.

Discuss this question

3. The summary TextView text survived rotation in the lab because it was saved in:

  1. The manifest
  2. strings.xml
  3. A Toast
  4. onSaveInstanceState()

Answer: D) onSaveInstanceState()

Explanation: The value was put in the Bundle and restored in onCreate.

Discuss this question

4. Which property tells whether a CheckBox is ticked?

  1. isSelected
  2. value
  3. checkedId
  4. isChecked

Answer: D) isChecked

Explanation: isChecked returns true when ticked.

Discuss this question

5. Radio buttons are made mutually exclusive by placing them inside a:

  1. LinearLayout only
  2. RadioGroup
  3. Spinner
  4. CheckBox

Answer: B) RadioGroup

Explanation: A RadioGroup allows only one checked RadioButton.

Discuss this question

6. The attribute that shows grey example text inside an empty EditText is:

  1. android:label
  2. android:text
  3. android:placeholderText only
  4. android:hint

Answer: D) android:hint

Explanation: hint displays guidance text until the user types.

Discuss this question

7. Which inputType hides the characters typed in a password field?

  1. phone
  2. textMultiLine
  3. textPersonName
  4. textPassword

Answer: D) textPassword

Explanation: textPassword masks the characters.

Discuss this question

8. rgGender.clearCheck() will:

  1. Validate the form
  2. Unselect all radio buttons in the group
  3. Delete the group
  4. Select Male

Answer: B) Unselect all radio buttons in the group

Explanation: clearCheck() removes the selection.

Discuss this question

9. Which Android class provides a ready-made pattern to validate email addresses?

  1. Regex.EMAIL
  2. EmailValidator.java
  3. InputType.EMAIL
  4. android.util.Patterns.EMAILADDRESS

Answer: D) android.util.Patterns.EMAILADDRESS

Explanation: Patterns.EMAILADDRESS.matcher(email).matches() checks the format.

Discuss this question

10. A two-column landscape version of the form should be placed in:

  1. res/values-land/strings.xml
  2. res/layout-land/activitymain.xml
  3. res/layout-port
  4. res/drawable-land

Answer: B) res/layout-land/activitymain.xml

Explanation: The -land qualifier selects the landscape layout.

Discuss this question

11. Which widget lets the user type text?

  1. TextView
  2. RadioButton
  3. ImageView
  4. EditText

Answer: D) EditText

Explanation: EditText is the editable text field.

Discuss this question

12. etEmail.error = "Invalid email" is used to:

  1. Close the keyboard
  2. Send an email
  3. Show an error message and icon on the field
  4. Clear the field

Answer: C) Show an error message and icon on the field

Explanation: setError marks the field as invalid.

Discuss this question

13. rgGender.checkedRadioButtonId returns -1 when:

  1. The first button is checked
  2. No radio button in the group is selected
  3. The group is invisible
  4. Both buttons are checked

Answer: B) No radio button in the group is selected

Explanation: -1 means nothing is checked.

Discuss this question

14. Which Material component provides a floating label and inline error for text fields?

  1. TextInputLayout
  2. MaterialCardView
  3. Chip
  4. Snackbar

Answer: A) TextInputLayout

Explanation: TextInputLayout wraps a TextInputEditText with label and error.

Discuss this question

15. After rotation, the text typed into EditTexts with IDs is:

  1. Restored automatically by the framework
  2. Sent to the server
  3. Always lost
  4. Moved to SharedPreferences

Answer: A) Restored automatically by the framework

Explanation: Views with IDs save and restore their own state.

Discuss this question

Practise Lab: Registration Form UI MCQs

More Computer Science chapters