• Tutorials
  • Courses
  • Tracks

Advanced Java Quiz Day 55

Last Updated :
Discuss
Comments

Question 1

Which Spring Data JPA interface is commonly used for pagination and sorting support?

  • CrudRepository

  • PagingAndSortingRepository

  • JpaEntityManager

  • EntityRepository

Question 2

Which JpaRepository method supports pagination?

  • findAll(Pageable pageable)

  • findAllWithLimit()

  • findAllPaginated()

  • findAll(int page, int size)

Question 3

How do you specify sorting in Spring Data JPA without pagination?

  • Use Sort parameter in findAll(Sort sort)

  • Use OrderBy clause only in queries

  • Use SQL ORDER keyword directly in entity

  • Set sorting in application.properties

Question 4

Which of the following creates a Pageable object for page number 0 and size 10, sorted by name ascending?

  • PageRequest.of(0, 10, Sort.by("name").ascending())

  • new Pageable(0, 10, "name")

  • PageRequest.create(0, 10, "name", "asc")

  • Pageable.of(0, 10, name asc)

Question 5

What is the main purpose of the Specification interface in Spring Data JPA?

  • To perform native SQL queries

  • To dynamically build type-safe queries using criteria

  • To configure caching in repositories

  • To create stored procedures


Question 6

Which package contains the Specification interface in Spring Data JPA?

  • org.springframework.data.jpa.domain

  • org.springframework.data.jpa.repository

  • javax.persistence.criteria

  • org.hibernate.jpa.spec

Question 7

What is the root object in the Criteria API used for building queries?

  • CriteriaQuery

  • Root<T>

  • EntityManager

  • Predicate

Question 8

Which advantage does Criteria API have over JPQL?

  • Queries are shorter and faster

  • Queries are database-specific

  • Queries are constructed dynamically and type-safe

  • Queries can only be written at compile-time

There are 8 questions to complete.

Take a part in the ongoing discussion