Bird
0
0

Which of the following is the correct syntax to define a Spring Data JPA repository interface for an entity named Product with primary key type Long?

easy📝 Syntax Q3 of 15
Spring Boot - Docker and Deployment
Which of the following is the correct syntax to define a Spring Data JPA repository interface for an entity named Product with primary key type Long?
Apublic interface ProductRepository extends CrudRepository<Product> {}
Bpublic class ProductRepository implements JpaRepository<Product, Long> {}
Cpublic interface ProductRepository extends JpaRepository<Product, Long> {}
Dpublic interface ProductRepository extends JpaRepository<Long, Product> {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct interface extension

    Spring Data JPA repositories are interfaces extending JpaRepository.
  2. Step 2: Check type order and interface usage

    public interface ProductRepository extends JpaRepository {} correctly uses interface, correct generic order, and empty body.
  3. Final Answer:

    public interface ProductRepository extends JpaRepository {} -> Option C
  4. Quick Check:

    JpaRepository syntax = public interface ProductRepository extends JpaRepository {} [OK]
Quick Trick: JpaRepository is interface syntax [OK]
Common Mistakes:
  • Using class instead of interface
  • Swapping generic parameters order
  • Omitting ID type in generics

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes