Fu Dong Jia

Ranch Hand
+ Follow
since May 23, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fu Dong Jia

I passed scbcd5 with 100% on Dec 20.
Thanks to all java ranch people!
I read Enterprise Javabeans 5th(O'REILLY)and the related spec.
9 years ago
Give the following clientside code:


10.@EJB Foo f1;
11.@EJB Foo f2;
//more code here
20.boolean test1=f1.equals(f1);
21.boolean test2=f1.equals(f2);
...


If Foo is stateless,test1 is true(of course).
I think test2 is false,because a method equals() have been invoked on f1,so container have been offered a special Foo instance to f1,so f1 is not equals to f2.But the answer for test2 is true.
beg for help!
I think that's a valuable question.
Can anyone explain it?
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.

Why the answer is 2,but not 3?


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.


(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 ]
The mock question come form Sun's Free Proficiency Assessment System.


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


If the answer is 3?
In J2se environment,if the same EntityTransaction instance returned every time when invoke EntityManager.getTransaction()?
[ December 12, 2008: Message edited by: Fu Dong Jia ]


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;
/* ... */
}



I think 2 and 3 are correct,am i right?
If the different entities within the persistence unit can share the same table generator?


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.


Is the answer is 2?


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.


I think the answer is 1,am i correct?