*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes A question form Sun's Free Proficiency Assessment System Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "A question form Sun Watch "A question form Sun New topic
Author

A question form Sun's Free Proficiency Assessment System

Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131

22. Given an excerpt from an entity:

10. @Entity
11. public class Koala {
12. int children;
13. @Id
14. private Integer id;
15. /* ... */
16. }
The following code was written to find the sum and average number of children across all Koala entities (assume the variable em is bound to a valid EntityManager instance):

20. String query = "SELECT SUM(k.children), AVG(k.children) from Koala k";
21. Query q = em.createQuery(query);
22. Object[] res = (Object []) q.getSingleResult();
Which two statements are correct? (Choose two.)
1,If there are no Koala entities in the database, the variable res is set to null after the code exits on line 22.
2,If there are no Koala entities in the database, the variable res contains an array of two null values.
3,If there are no Koala entities in the database, the variable res contains an array holding the values null and 0 respectively.
4,If there are Koala entities, the variable res contains an array with values of type Long and Double, respectively.
5,This code throws a runtime exception.


I think the only correct answer is 2.
If there are Koala entities, the variable res contains an array with values of type Integer and Double.


who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
Chaminda Amarasinghe
Ranch Hand

Joined: May 17, 2006
Posts: 402
Seems you are looking for answers to SFPAS

here it is
Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131
Thanks Chaminda very much,that's just what I need!

The answer for this question is 2 and 4.but i think the answer 4 should be midified to:
4,If there are Koala entities, the variable res contains an array with values of type INTEGER and Double, respectively.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A question form Sun's Free Proficiency Assessment System
 
Similar Threads
Answers of Sun's Free Proficiency Assessment
Hibernate JPQL/HQL: aggregate functions show results of wrong table/entity joined twice
Sun Cirtification
Doubt in Sun's sample question
A question aboute EJB-QL