MCQs / Computer Science / UI Events, Views, Preferences and Data Storage

UI Events, Views, Preferences and Data Storage MCQs — Computer Science (page 2)

39 multiple-choice questions on UI Events, Views, Preferences and Data Storage 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.

26. MODEPRIVATE means the preferences file:

  1. Is encrypted automatically
  2. Is shared with all apps
  3. Can be accessed only by the app that created it
  4. Is deleted on restart

Answer: C) Can be accessed only by the app that created it

Explanation: Private mode restricts access to the calling app.

Discuss this question

27. An Adapter is a:

  1. Layout manager
  2. Bridge between a data source and a list view that creates a view for each item
  3. Type of intent
  4. Database

Answer: B) Bridge between a data source and a list view that creates a view for each item

Explanation: Adapters bind data items to row views.

Discuss this question

28. SharedPreferences data is saved on the device in a/an:

  1. SQLite database
  2. Text file on the SD card
  3. Server
  4. XML file in the app's private sharedprefs folder

Answer: D) XML file in the app's private sharedprefs folder

Explanation: Each preferences file is an XML file under /data/data/package/sharedprefs.

Discuss this question

29. Callback methods such as onTouchEvent() that you override in a custom view are called:

  1. Intents
  2. Event handlers
  3. Listeners
  4. Adapters

Answer: B) Event handlers

Explanation: Event handlers are overridden in the view class itself.

Discuss this question

30. Which call saves preference changes asynchronously?

  1. flush()
  2. save()
  3. commit()
  4. apply()

Answer: D) apply()

Explanation: apply() writes in the background; commit() is synchronous and returns a Boolean.

Discuss this question

31. Which method opens a private file for writing in internal storage?

  1. getExternalStorageDirectory()
  2. File("sdcard/notes.txt")
  3. openRawResource()
  4. openFileOutput("notes.txt", MODEPRIVATE)

Answer: D) openFileOutput("notes.txt", MODEPRIVATE)

Explanation: openFileOutput writes to the app's private filesDir.

Discuss this question

32. Which interface notifies an app as the user types in an EditText?

  1. OnLongClickListener
  2. OnClickListener
  3. TextWatcher
  4. OnItemSelectedListener

Answer: C) TextWatcher

Explanation: TextWatcher has before/on/afterTextChanged callbacks.

Discuss this question

33. Android's built-in lightweight relational database is:

  1. Oracle
  2. MongoDB
  3. MySQL
  4. SQLite

Answer: D) SQLite

Explanation: SQLite is embedded in Android.

Discuss this question

34. A query on an SQLite database returns a:

  1. Cursor
  2. View
  3. Intent
  4. Bundle

Answer: A) Cursor

Explanation: A Cursor iterates over query result rows.

Discuss this question

35. Google's modern, coroutine-based replacement for SharedPreferences is:

  1. Room
  2. ContentProvider
  3. Jetpack DataStore
  4. WorkManager

Answer: C) Jetpack DataStore

Explanation: DataStore stores key–value or typed data asynchronously with Flow.

Discuss this question

36. Writing files to the app's internal storage requires:

  1. INTERNET
  2. No permission
  3. WRITEEXTERNALSTORAGE
  4. READMEDIAIMAGES

Answer: B) No permission

Explanation: Internal app storage needs no permission.

Discuss this question

37. Why is RecyclerView more efficient than creating a view for every item?

  1. It loads all rows at once
  2. It runs on a server
  3. It uses fewer colours
  4. It recycles row views that scroll off-screen using ViewHolders

Answer: D) It recycles row views that scroll off-screen using ViewHolders

Explanation: Recycling reduces memory use and keeps scrolling smooth.

Discuss this question

38. Reading the phone's contacts through the Contacts provider requires:

  1. No permission
  2. INTERNET
  3. READCONTACTS permission
  4. CALLPHONE

Answer: C) READCONTACTS permission

Explanation: Contacts are protected by a dangerous runtime permission.

Discuss this question

39. Which mechanism is the simplest way to send text to another app chosen by the user?

  1. ACTIONSEND share intent
  2. Content provider
  3. Room
  4. SQLite

Answer: A) ACTIONSEND share intent

Explanation: The share intent lets the user pick the target app.

Discuss this question

Previous Page 2 of 2

Practise UI Events, Views, Preferences and Data Storage MCQs

More Computer Science chapters