MCQs / Computer Science / Messaging: SMS and Email

Messaging: SMS and Email MCQs — Computer Science

31 multiple-choice questions on Messaging: SMS and Email 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 should an app NOT contain an SMTP username and password to send emails?

  1. Android blocks all SMTP
  2. Emails cannot have subjects
  3. They can be extracted from the APK and misused
  4. SMTP is slower than SMS

Answer: C) They can be extracted from the APK and misused

Explanation: Secrets in apps can be reverse engineered; use a backend server instead.

Discuss this question

2. Which extra sets the email subject?

  1. EXTRATEXT
  2. EXTRASUBJECT
  3. EXTRATITLE
  4. EXTRAHEADER

Answer: B) EXTRASUBJECT

Explanation: EXTRASUBJECT holds the subject line.

Discuss this question

3. Which extra is used to attach a file to an email?

  1. EXTRADATA
  2. EXTRAATTACH
  3. EXTRASTREAM (with a content URI)
  4. EXTRAFILE

Answer: C) EXTRASTREAM (with a content URI)

Explanation: EXTRASTREAM carries the attachment's URI.

Discuss this question

4. On Android 12 (API 31) and above, the recommended way to get SmsManager is:

  1. SmsManager.getDefault() only
  2. getSystemService(SmsManager::class.java)
  3. TelephonyManager.getSms()
  4. new SmsManager()

Answer: B) getSystemService(SmsManager::class.java)

Explanation: getDefault() is deprecated from API 31.

Discuss this question

5. Which extra key pre-fills the SMS text in the Messages app?

  1. "smsbody"
  2. "textmessage"
  3. Intent.EXTRAEMAIL
  4. Intent.EXTRASUBJECT

Answer: A) "smsbody"

Explanation: The messaging app reads the "smsbody" extra.

Discuss this question

6. INTERNET permission is:

  1. Only for system apps
  2. Restricted by Play policy
  3. A normal permission granted at install time
  4. A dangerous runtime permission

Answer: C) A normal permission granted at install time

Explanation: Normal permissions are granted automatically.

Discuss this question

7. Two emulators can send SMS to each other using:

  1. Bluetooth
  2. The emulator console port number (e.g. 5554) as the phone number
  3. Their IP addresses
  4. Their package names

Answer: B) The emulator console port number (e.g. 5554) as the phone number

Explanation: Each emulator's port works as its phone number.

Discuss this question

8. The sentIntent and deliveryIntent of sendTextMessage are of type:

  1. Uri
  2. Intent
  3. Bundle
  4. PendingIntent

Answer: D) PendingIntent

Explanation: They are PendingIntents broadcast by the system later.

Discuss this question

9. Which URI scheme is used with ACTIONSENDTO to open an SMS app?

  1. geo:
  2. tel:
  3. mailto:
  4. smsto:

Answer: D) smsto:

Explanation: smsto: (or sms:) targets messaging apps.

Discuss this question

10. A receiver registered in code (registerReceiver) is called a:

  1. Sticky receiver
  2. Manifest receiver
  3. Static receiver
  4. Dynamic (context-registered) receiver

Answer: D) Dynamic (context-registered) receiver

Explanation: Context-registered receivers live while their context is active.

Discuss this question

11. Which approach sends an SMS WITHOUT needing any permission?

  1. A BroadcastReceiver
  2. ContentResolver.insert()
  3. An implicit intent that opens the Messages app
  4. SmsManager.sendTextMessage()

Answer: C) An implicit intent that opens the Messages app

Explanation: The SMS intent lets the user's Messages app send it after the user confirms.

Discuss this question

12. Which method checks whether a permission is already granted?

  1. shouldShowRequestPermissionRationale()
  2. requestPermissions()
  3. ContextCompat.checkSelfPermission()
  4. grantUriPermission()

Answer: C) ContextCompat.checkSelfPermission()

Explanation: checkSelfPermission returns PERMISSIONGRANTED or PERMISSIONDENIED.

Discuss this question

13. An SMS written in Urdu (Unicode) can hold up to:

  1. 300 characters
  2. 70 characters
  3. 140 characters
  4. 160 characters

Answer: B) 70 characters

Explanation: UCS-2 Unicode reduces the limit to 70 characters.

Discuss this question

14. From which Android version must dangerous permissions be requested at run time?

  1. 6.0 (API 23)
  2. 12
  3. 4.4
  4. 9

Answer: A) 6.0 (API 23)

Explanation: Runtime permissions started in Marshmallow.

Discuss this question

15. Which intent opens ONLY email apps?

  1. ACTIONDIAL with tel:
  2. ACTIONSENDTO with a mailto: URI
  3. ACTIONSEND with type text/plain
  4. ACTIONVIEW with https:

Answer: B) ACTIONSENDTO with a mailto: URI

Explanation: mailto: with SENDTO is handled only by email clients.

Discuss this question

16. In sendTextMessage(destination, scAddress, text, sentIntent, deliveryIntent), passing null for scAddress means:

  1. Use the default SMS centre
  2. Do not send
  3. Send as email
  4. Send to all contacts

Answer: A) Use the default SMS centre

Explanation: null uses the phone's default service centre.

Discuss this question

17. shouldShowRequestPermissionRationale() returns true when:

  1. The user previously denied and the app should explain why it needs the permission
  2. The app is first installed
  3. The permission is granted
  4. The device has no SIM

Answer: A) The user previously denied and the app should explain why it needs the permission

Explanation: It signals that an explanation should be shown before asking again.

Discuss this question

18. Why should the Send button be disabled after it is tapped?

  1. To close the app
  2. To request permission
  3. To save the layout
  4. To give feedback and prevent sending duplicate messages

Answer: D) To give feedback and prevent sending duplicate messages

Explanation: Disabling or changing the button shows progress and avoids double sends.

Discuss this question

19. SmsManager.RESULTERRORRADIOOFF usually means:

  1. No SIM balance
  2. Message too long
  3. Wrong number format
  4. The phone is in airplane mode / radio is off

Answer: D) The phone is in airplane mode / radio is off

Explanation: The cellular radio was turned off.

Discuss this question

20. Which component receives the SENT and DELIVERED broadcasts?

  1. Service only
  2. Fragment
  3. BroadcastReceiver
  4. ContentProvider

Answer: C) BroadcastReceiver

Explanation: A BroadcastReceiver's onReceive handles the result.

Discuss this question

21. ACTIONSEND (instead of SENDTO) shows:

  1. Only the browser
  2. No apps
  3. All apps that can share the given MIME type
  4. Only email apps

Answer: C) All apps that can share the given MIME type

Explanation: ACTIONSEND is a general share action.

Discuss this question

22. Which method splits a long text into parts?

  1. breakText()
  2. divideMessage()
  3. substringSms()
  4. splitSms()

Answer: B) divideMessage()

Explanation: divideMessage returns a list of parts for sendMultipartTextMessage.

Discuss this question

23. SMS messages are routed through the operator's:

  1. SMSC (Short Message Service Centre)
  2. Web server
  3. SMTP server
  4. DNS server

Answer: A) SMSC (Short Message Service Centre)

Explanation: The SMSC stores and forwards SMS messages.

Discuss this question

24. A single SMS using the standard GSM 7-bit alphabet can hold up to:

  1. 160 characters
  2. 1000 characters
  3. 255 characters
  4. 70 characters

Answer: A) 160 characters

Explanation: GSM-7 encoding allows 160 characters per SMS.

Discuss this question

25. Which API lets an app read a one-time password SMS without SMS permissions?

  1. TelephonyManager
  2. SmsManager
  3. SMS User Consent / SMS Retriever API
  4. ContactsContract

Answer: C) SMS User Consent / SMS Retriever API

Explanation: Google Play services APIs retrieve OTP messages without READSMS.

Discuss this question

Page 1 of 2 Next

Practise Messaging: SMS and Email MCQs

More Computer Science chapters