Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the Pageable interface in Spring Boot?
The Pageable interface helps to request a specific page of data with a defined size and sorting order. It makes it easy to handle pagination and sorting in database queries.
Click to reveal answer
beginner
How do you specify sorting when using Pageable?
You can specify sorting by using PageRequest.of(page, size, Sort.by("fieldName").ascending()) or PageRequest.of(page, size, Sort.by("fieldName").descending()) to sort the results by a field in ascending or descending order.
Click to reveal answer
intermediate
What does the Page object returned by a repository method contain?
The Page object contains the list of items for the requested page, total number of pages, total number of elements, current page number, and page size. It helps to navigate through paged data easily.
Click to reveal answer
beginner
How can you enable pagination and sorting in a Spring Data JPA repository method?
Add a Pageable parameter to the repository method signature, for example: Page<Entity> findAll(Pageable pageable);. Spring Data will automatically apply pagination and sorting based on the Pageable argument.
Click to reveal answer
advanced
What is the difference between Pageable and Slice in Spring Data?
Pageable returns a Page which contains total count information, while Slice only knows if there is a next slice available and does not fetch total count, which can improve performance when total count is not needed.
Click to reveal answer
Which method creates a Pageable object for page 2 with 10 items per page sorted by 'name' ascending?