MCQs / Computer Science / Lab: Showing a Location on Google Maps

Lab: Showing a Location on Google Maps MCQs — Computer Science

12 multiple-choice questions on Lab: Showing a Location on Google Maps 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. In onMapReady, which call centres the map on a position at zoom 15?

  1. map.center = pos
  2. map.zoomTo(pos, 15)
  3. map.camera(15)
  4. map.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, 15f))

Answer: D) map.moveCamera(CameraUpdateFactory.newLatLngZoom(pos, 15f))

Explanation: CameraUpdateFactory creates the camera update.

Discuss this question

2. Which Android Studio template creates a ready map screen?

  1. Navigation Drawer Views Activity
  2. Empty Views Activity
  3. Login Views Activity
  4. Google Maps Views Activity

Answer: D) Google Maps Views Activity

Explanation: The Google Maps template sets up SupportMapFragment and the key placeholder.

Discuss this question

3. toDoubleOrNull() is used so that:

  1. The keyboard closes
  2. The app requests location permission
  3. The number is rounded
  4. Invalid text returns null instead of crashing

Answer: D) Invalid text returns null instead of crashing

Explanation: It safely converts strings to Double.

Discuss this question

4. Why does the lab fall back to a https://www.google.com/maps/... URL?

  1. To save battery
  2. Because geo: URIs need a key
  3. To use satellite view
  4. To open the map in a browser if the Google Maps app is not installed

Answer: D) To open the map in a browser if the Google Maps app is not installed

Explanation: The universal Maps URL works in any browser.

Discuss this question

5. setPackage("com.google.android.apps.maps") on the intent ensures that:

  1. No app opens
  2. The browser opens
  3. An API key is used
  4. The Google Maps app specifically handles the intent

Answer: D) The Google Maps app specifically handles the intent

Explanation: setPackage limits the intent to that app.

Discuss this question

6. To restrict a Maps API key to your app you need the package name and the app's:

  1. versionCode
  2. launcher icon
  3. SHA-1 certificate fingerprint
  4. minSdk

Answer: C) SHA-1 certificate fingerprint

Explanation: Android key restrictions use package name + SHA-1.

Discuss this question

7. Which longitude value is INVALID?

  1. 0
  2. 190.5
  3. -122.4
  4. 73.0479

Answer: B) 190.5

Explanation: Longitude must be between -180 and 180.

Discuss this question

8. Where should the Maps API key be stored to avoid committing it to GitHub?

  1. The layout file
  2. strings.xml in the public repository
  3. The app name
  4. local.properties (read through the Secrets Gradle Plugin)

Answer: D) local.properties (read through the Secrets Gradle Plugin)

Explanation: local.properties is excluded from version control by default.

Discuss this question

9. osmdroid is a good option in this lab because it:

  1. Shows only satellite images
  2. Is Google's official SDK
  3. Works without internet in all cases
  4. Displays OpenStreetMap maps without a Google API key or billing

Answer: D) Displays OpenStreetMap maps without a Google API key or billing

Explanation: osmdroid uses free OpenStreetMap tiles.

Discuss this question

10. In geo:33.7295,73.0372?z=16, the value 16 is the:

  1. Marker colour
  2. Zoom level
  3. Number of results
  4. Latitude

Answer: B) Zoom level

Explanation: z sets the zoom level.

Discuss this question

11. Which inputType allows decimals and negative numbers for coordinates?

  1. phone
  2. textUri
  3. number
  4. numberDecimalnumberSigned

Answer: D) numberDecimalnumberSigned

Explanation: Coordinates need a decimal point and may be negative.

Discuss this question

12. Which URI starts driving navigation in Google Maps?

  1. maps:navigate
  2. geo:drive?33.7,73.0
  3. google.navigation:q=33.7,73.0&mode=d
  4. https://drive.google.com

Answer: C) google.navigation:q=33.7,73.0&mode=d

Explanation: google.navigation: with mode=d starts driving navigation.

Discuss this question

Practise Lab: Showing a Location on Google Maps MCQs

More Computer Science chapters