Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Question Reg parameter Passing - HFEJB Pg No 170

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Givn Remote client 'R' that has valid reference to session bean 'A' and 'B', and given that 'A' is local client to 'B', which statement are true. (Choose all that apply)

A. R Cannot passs his reference for A, to B.

B. A Cannot pass his reference for B, to R.

C. A Cannot invoke method of B.

D. B cannot invoke method on R.

{Correct answer give was B and D.}

Can you pls. explain why A is not valid and B is valid.
My assumption is R is in one heap and Sesson bean A,B are in another heap. So R will not pass reference it can pass only reference copy.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You are correct, R is in a different heap than A & B. R's reference to A is nothing but a Stub.
Hence in side code, when R passes a reference of A to anybody it is actually passing the copy of the stub. And that is OK.
If R passes a copy of A's stub to B, then B can call methods or do other stuff on A as an remote object (though they are in the same heap).
Option (A) says that R Can not pass a reference of A to B (if fact it can) hence A is not correct.

Option (B) says that A can not pass it’s reference for B to R, yes it can not. Because A & B are LOCAL and they are not dealing with stubs they are dealing with actual references. Those references do not have any value to R being in a separate heap. Hence B is correct.

Let me know if you have any different opinion.
 
Natarajan Shankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Amitava Basu,
Thanks for your clarificatio.

when R passes a reference of A to anybody it is actually passing the copy of the stub.
And that is OK.



The above clarification you have given was the point I was missing in my understanding, when R passes a reference of A I was assuming the actual object reference. Thanks for you clarification. BTW, this solution will satisfy if we're assuiming this one.
 
reply
    Bookmark Topic Watch Topic
  • New Topic