• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

question about remote interface param

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
mock question(from actualtests.com)

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 java.io.Serializable
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;
13. fooRef.foo(data);
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?
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Oh. Hi guys! Look at this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic