🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: API Design: all 15 questions

Quiz: API Design · Question 3 of 15

What does this print? (code)

What does this print?

items = [6, 5, 4, 3, 2, 1]
page1 = items[0:2]
items.insert(0, 7)
page2 = items[2:4]
print(page1, page2)
  1. A.[6, 5] [4, 3]
  2. B.[6, 5] [5, 4]
  3. C.[7, 6] [5, 4]
  4. D.[6, 5] [3, 2]
Answer & explanation

Correct answer: [6, 5] [5, 4]

The new item 7 shifts everything one place, so offset 2 now starts at 5 — a repeat. This is the offset pagination problem.

Can you get the rest right without peeking?

Take the timed Quiz: API Design quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →