MCQs / Computer Science / Lab: Supabase Backend and Retrofit

Lab: Supabase Backend and Retrofit MCQs — Computer Science

12 multiple-choice questions on Lab: Supabase Backend and Retrofit 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. Which policy lets users who are not signed in read notices?

  1. for insert to anon with check (false)
  2. No policy is needed with RLS on
  3. for select to anon, authenticated using (true)
  4. for delete using (true)

Answer: C) for select to anon, authenticated using (true)

Explanation: anon is the role without a signed-in user.

Discuss this question

2. Why does inserting a 2-character notice fail even with an insert policy?

  1. Gson cannot send short strings
  2. Retrofit trims it
  3. RLS blocks short text
  4. The CHECK constraint requires 3–200 characters

Answer: D) The CHECK constraint requires 3–200 characters

Explanation: Constraints still apply after RLS allows the insert.

Discuss this question

3. Which call shows a newly posted notice in the list?

  1. Restarting the emulator
  2. Clearing app data
  3. Calling load() again after the insert succeeds
  4. notifyItemRemoved(0)

Answer: C) Calling load() again after the insert succeeds

Explanation: Re-fetching updates the adapter.

Discuss this question

4. A 404 from /rest/v1/notice (without s) most likely means:

  1. The body was too long
  2. The key expired
  3. RLS blocked it
  4. The table name is wrong

Answer: D) The table name is wrong

Explanation: PostgREST returns 404 for an unknown table.

Discuss this question

5. "Unresolved reference: BuildConfig" is fixed by:

  1. Renaming MainActivity
  2. Deleting local.properties
  3. buildConfig = true in buildFeatures and rebuilding
  4. Adding INTERNET permission

Answer: C) buildConfig = true in buildFeatures and rebuilding

Explanation: BuildConfig generation is off by default in new projects.

Discuss this question

6. Why can't you test the notices API by just opening the URL in a browser?

  1. The URL must start with ftp
  2. Browsers cannot show JSON
  3. The apikey must be sent in a request header
  4. Supabase blocks Chrome

Answer: C) The apikey must be sent in a request header

Explanation: Use curl or Postman to add headers.

Discuss this question

7. UnknownHostException in SupaNotes usually means:

  1. No internet or wrong host name
  2. The adapter is empty
  3. RLS denied the request
  4. The table has no rows

Answer: A) No internet or wrong host name

Explanation: DNS failed to resolve the host.

Discuss this question

8. The baseUrl passed to Retrofit must:

  1. Contain the table name
  2. End with a slash
  3. Use http only
  4. Include the API key

Answer: B) End with a slash

Explanation: Retrofit requires a trailing / on baseUrl.

Discuss this question

9. Which permission must SupaNotes declare?

  1. SENDSMS
  2. android.permission.INTERNET
  3. ACCESSFINELOCATION
  4. CAMERA

Answer: B) android.permission.INTERNET

Explanation: Network calls need INTERNET.

Discuss this question

10. In the lab, "generated always as identity" on the id column means:

  1. The id can be edited
  2. The id is a UUID
  3. The app must send an id
  4. The database numbers rows automatically

Answer: D) The database numbers rows automatically

Explanation: Identity columns auto-increment.

Discuss this question

11. Why are id and createdat not sent when posting a notice?

  1. They are sent as zero
  2. Retrofit deletes them
  3. Gson skips null fields, so the database fills them in
  4. Supabase forbids those names

Answer: C) Gson skips null fields, so the database fills them in

Explanation: Defaults are applied by the database.

Discuss this question

12. In curl, -H "apikey: …" adds:

  1. A request header
  2. A cookie file
  3. A JSON body
  4. A query parameter

Answer: A) A request header

Explanation: -H sets headers; -d sends a body.

Discuss this question

Practise Lab: Supabase Backend and Retrofit MCQs

More Computer Science chapters