File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes question about remote interface param 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 "question about remote interface param" Watch "question about remote interface param" New topic

question about remote interface param

vitesse wei
Ranch Hand

Joined: Sep 07, 2007
Posts: 100
mock question(from

A developer writes a stateless session bean FooBean with one remote business interface FooRemote containing one business method foo. Method foo takes a single parameter of application-defined type MyData.
11. public class MyData implements
12. int a;
13. }
Method foo is implemented within the FooBean class as:
11. public void foo(MyData data) {
12. data.a=2;
13. }
Another session bean within the same application has a reference to FooRemote in variable
fooRef and calls method foo with the following code:
11. MyData data = new MyData();
12. data.a=1;
14. System.out.println(data.a);
What is the value of data.a when control reaches Line 14 of the client?
A. 0
B. 1
C. 2
D. either 1 or 2

given answer is B,why?data is serializable,is this test for pass-by-value or pass-by-reference?

SCJP 5.0<br />SCWCD1.4<br />SCBCD5
Tushar Roy

Joined: Mar 26, 2008
Posts: 29
When a class is serializable it means that it can be passed as remote objects. When an object is passed as remote object they are always passed by value. So in this case the object is passed as value.

Tushar<br /> <br />SCJP 5 (95%)<br />SCWCD 1.4 (92%)<br />SCBCD 5 (93%)
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 389
In case of remote invocations, data is always copied.

Would the data be still copied if the bean is deployed on the same VM. I mean if the user chooses to provide a remote interface instead of local one. I think in that case too the data could be copied.

SCJP 1.4, SCWCD 1.4, SCBCD 1.5, TOGAF 9, Comptia Cloud+
I agree. Here's the link:
subject: question about remote interface param
It's not a secret anymore!