Java EE 7 Application Developer — Question 23
Given the JPQL code fragment:
Select pub.title, pub.author, pub.pages FROM Publisher pub
Which two clauses do you add to this JPQL query to retrieve only those books with between 500 and 750 total pages? (Choose two.)
Answer options
- A. WHERE MIN(pages) >= 500 AND MAX(pages) <= 750
- B. WHERE pub.pages <= 500 OR pub.pages >= 750
- C. WHERE pub.pages BETWEEN 500 AND 750
- D. WHERE pub.pages <= 500 AND pub.pages >=750
Correct answer: A, B
Explanation
The correct answer is C, which properly uses the BETWEEN clause to filter for pages within the specified range. Options A and B do not correctly define the criteria for the page count, as A incorrectly uses aggregate functions and B uses an OR condition which does not meet the requirement.