10.@EJB Foo f1;
11.@EJB Foo f2;
//more code here
20.boolean test1=f1.equals(f1);
21.boolean test2=f1.equals(f2);
...
4,If there are Koala entities, the variable res contains an array with values of type INTEGER and Double, respectively.
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.
(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.
20. Which method of the EntityManager API is used to control the life-cycle of an application-managed persistence context?
1, EntityManager.remove
2, EntityManager.refresh
3, EntityManager.joinTransaction
4, EntityManager.getReference
15. There are two tables in a database, Celery and Carrot. Celery contains a foreign key to Carrot. Each table has a primary key, and there are no other constraints on the tables. No descriptors are used, and in the following options each scenario depicts all the mapping information pertaining to the relationship. Which entities accurately model this database scenario?
1,@Entity Celery {
/* ... */
}
@Entity Carrot {
@ManyToOne
Celery celery;
/* ... */
}
2,@Entity Celery {
@ManyToOne
Carrot carrot;
/* ... */
}
@Entity Carrot {
/* ... */
}
3,@Entity Celery {
@OneToOne
Carrot carrot;
/* ... */
}
@Entity Carrot {
/* ... */
}
4,@Entity Celery {
/* ... */
}
@Entity Carrot {
@OneToOne
Carrot carrot;
/* ... */
}
Which statement about EJB 2.x and EJB 3.0 API interoperability is correct?
1,A stateless session bean written to the EJB 3.0 API can be adapted to an EJB 2.1 client interface.
2,The developer cannot mix APIs. For example, the developer cannot write an EJB 3.0 session bean while also implementing an EJB 2.1 EJBHome interface.
3,The EJB 2.1 API requires the use of a stateful session bean's home interface to obtain a reference to the bean's component interface. The developer cannot use dependency injection to obtain a reference to such a home interface in an EJB 3.0 client of such a bean.
4,An adapter class has to be used when accessing EJB 2.0 environment variables of a stateless session bean, when such a bean is deployed in an EJB 3.0 container.
What programming restrictions are defined in the EJB specifications?
1,An enterprise bean must NOT attempt to listen on a socket.
2,A session bean class must NOT have any superclasses and/or superinterfaces.
3,An enterprise bean can directly read a file descriptor.
4,An entity bean class need NOT implement a public zero-argument constructor.