This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes A question aboute EJB-QL 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 aboute EJB-QL " Watch "A question aboute EJB-QL " New topic
Author

A question aboute EJB-QL

Fu Dong Jia
Ranch Hand

Joined: May 23, 2007
Posts: 131

(quoted from Sun's Free Proficiency Assessment System )
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.
[ December 11, 2008: Message edited by: Fu Dong Jia ]

who dare win!<br />SCJP5(94%)|SCWCD5(86%)|SCBCD(100%)|SCEA in progress
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Me again Can you give a meaningful subject line to your threads ? Naming them all "A question form Sun's Free Proficiency Assessment System" makes it difficult to follow. Thank you
You can edit them by clicking the icon.


[My Blog]
All roads lead to JavaRanch
 
GeeCON Prague 2014
 
subject: A question aboute EJB-QL