Skills101
← All practice quizzes

Quiz: Pagination and Sorting

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Never send 50,000 rows in one response. Learn page and offset arithmetic, Spring Data's Pageable, Page and Sort, a clean paged REST endpoint, why sorting needs a tie-breaker, and keyset pagination for deep pages.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    With size = 20, what is the offset for page 3 (pages start at 0)?

  2. Question 2

    There are 101 courses and the page size is 10. How many pages are there?

  3. Question 3

    What does this print?

    import java.util.*;
    
    public class Main {
        public static void main(String[] args) {
            List<String> all = List.of("a", "b", "c", "d", "e", "f", "g");
            int size = 3, page = 2;
            int from = Math.min(page * size, all.size());
            int to = Math.min(from + size, all.size());
            System.out.println(all.subList(from, to) + " " + (int) Math.ceil(all.size() / (double) size));
        }
    }
    
  4. Question 4

    What does PageRequest.of(1, 10) request?

  5. Question 5

    What is the main difference between Page<T> and Slice<T>?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →