MCQs / Computer Science / Maps and Consuming Web Services over HTTP

Maps and Consuming Web Services over HTTP MCQs — Computer Science (page 2)

39 multiple-choice questions on Maps and Consuming Web Services over HTTP 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. Gson's @SerializedName annotation is used when:

  1. The JSON is an array
  2. Encrypting data
  3. The field is a number
  4. The JSON field name differs from the Kotlin property name

Answer: D) The JSON field name differs from the Kotlin property name

Explanation: It maps differently named JSON keys to properties.

Discuss this question

27. In MVVM, network calls should be placed in a:

  1. Layout XML
  2. Activity's onCreate only
  3. Repository used by a ViewModel
  4. BroadcastReceiver

Answer: C) Repository used by a ViewModel

Explanation: Repository + ViewModel separates data access from UI and survives rotation.

Discuss this question

28. The baseUrl given to Retrofit.Builder must:

  1. Use http only
  2. Be an IP address
  3. Contain a query string
  4. End with a slash (/)

Answer: D) End with a slash (/)

Explanation: Retrofit requires the base URL to end with /.

Discuss this question

29. Which HTTP method is used to READ data?

  1. POST
  2. PUT
  3. DELETE
  4. GET

Answer: D) GET

Explanation: GET retrieves resources.

Discuss this question

30. Which library is commonly used to load images from URLs into ImageViews?

  1. Room
  2. WorkManager
  3. Glide / Coil
  4. Retrofit

Answer: C) Glide / Coil

Explanation: Glide and Coil download, cache and display images.

Discuss this question

31. To draw a route line on a Google Map, use:

  1. addCircle
  2. addMarker
  3. setMapType
  4. addPolyline

Answer: D) addPolyline

Explanation: Polylines connect a list of LatLng points.

Discuss this question

32. An open-source alternative map library for Android is:

  1. MapKit
  2. Firebase Maps
  3. osmdroid (OpenStreetMap)
  4. Core Location

Answer: C) osmdroid (OpenStreetMap)

Explanation: osmdroid and MapLibre use open map data.

Discuss this question

33. Why should the API key be restricted to your package name and SHA-1 fingerprint?

  1. So other apps cannot misuse your key and your billing
  2. To make the map faster
  3. It is required for map intents
  4. To enable satellite view

Answer: A) So other apps cannot misuse your key and your billing

Explanation: Key restrictions prevent unauthorised use.

Discuss this question

34. In Retrofit, an HTTP API is described as a:

  1. JSON file
  2. Layout XML
  3. SQL table
  4. Kotlin/Java interface with annotated methods

Answer: D) Kotlin/Java interface with annotated methods

Explanation: Each interface method represents an endpoint.

Discuss this question

35. Which HTTP method normally CREATES a new resource?

  1. POST
  2. DELETE
  3. GET
  4. HEAD

Answer: A) POST

Explanation: POST submits data to create a resource.

Discuss this question

36. Checking whether the device has a network connection uses:

  1. TelephonyManager only
  2. LocationManager
  3. ConnectivityManager with NetworkCapabilities
  4. WifiManager.disable()

Answer: C) ConnectivityManager with NetworkCapabilities

Explanation: ConnectivityManager reports active network capabilities.

Discuss this question

37. Which call adds a pin at a position?

  1. map.addMarker(MarkerOptions().position(latLng).title("Campus"))
  2. map.setMarker(latLng)
  3. map.addPin(latLng)
  4. map.drawPoint(latLng)

Answer: A) map.addMarker(MarkerOptions().position(latLng).title("Campus"))

Explanation: MarkerOptions configures a marker added with addMarker.

Discuss this question

38. Status code 500 indicates:

  1. The resource was created
  2. Redirect
  3. Client typing error
  4. An internal server error

Answer: D) An internal server error

Explanation: 5xx codes are server-side errors.

Discuss this question

39. Status code 404 means:

  1. Unauthorized
  2. Server error
  3. Success
  4. Not Found

Answer: D) Not Found

Explanation: 404 indicates the requested resource does not exist.

Discuss this question

Previous Page 2 of 2

Practise Maps and Consuming Web Services over HTTP MCQs

More Computer Science chapters