1. In XML, a string resource named nameali is referenced as:
- string:nameali
- @string/nameali
- string/nameali
- R.string.nameali
Answer: B) @string/nameali
Explanation: XML uses @string/..., while code uses R.string....
MCQs / Computer Science / Lab: Student Information App Using Resources
16 multiple-choice questions on Lab: Student Information App Using Resources 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.
Answer: B) @string/nameali
Explanation: XML uses @string/..., while code uses R.string....
Answer: D) img.setImageResource(R.drawable.studentsara)
Explanation: setImageResource sets a drawable resource by ID.
Answer: C) Strings used when the device language is Urdu
Explanation: values-ur is a locale qualifier for Urdu resources.
Answer: B) res/drawable
Explanation: Images used by the UI are drawable resources.
Answer: B) sp
Explanation: sp scales with the user's font-size preference.
Answer: D) android:contentDescription
Explanation: contentDescription provides accessibility text.
Answer: B) centerCrop
Explanation: centerCrop scales uniformly and crops the overflow.
Answer: A) The default value from values/strings.xml
Explanation: Resources fall back to the default (unqualified) folder.
Answer: A) Density-independent pixels
Explanation: dp keeps sizes physically similar on screens of different densities.
Answer: B) studentali.jpg
Explanation: Resource names may contain only lowercase letters, digits and underscores, starting with a letter.
Answer: D) Cycle back to the first student after the last one
Explanation: The modulo wraps the index around to 0.
Answer: B) getString(R.string.name)
Explanation: getString(resId) returns the string value.
Answer: B) int
Explanation: Resource IDs are integer constants in the generated R class.
Answer: C) One below another
Explanation: orientation="vertical" stacks children from top to bottom.
Answer: D) android:src
Explanation: android:src points to a drawable resource.
Answer: C) findViewById()
Explanation: View Binding generates a class with direct references to views.
Practise Lab: Student Information App Using Resources MCQs