This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFEJB - question page 426 - # 4.

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
4 - Give the container-managed unidirectional relationship:

Foo(0-1) --> Bar (0-1)

And the object relations:

F1 --> B1
F2 --> B2

What will be true after the following code returns (Choose all)

f2.setBar(f1.getBar());

A - f1.getBar() == null
B - b2.getFoo() == null
C - b1.getBar() == null
D - none of the above

OK, here are my comments:

C - wrong - it does not make sense since b1 has getFoo() instead of getBar().

D - wrong, because A is correct and makes sense!

At last, my question is about letter B.

- Why b2.getFoo() istn't equals to null since the b1 Bar object took its place over ?

Tks in advance!!
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be null? A and B are the correct answers.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Amol!!

Right...in my point of view the both A and B would be correct!

A - f1.getBar() == null
B - b2.getFoo() == null

I was taking a look at the HFEJB errata, and i can see this:

[426] q4, ANSWER C;
--> b1.getBar() = null should be b1.getFoo() - right it makes sense and that's correct too!!

BUT anyway...in my understanding the option B and A are still correct since the relationship between these objects are one to one bidirectional and the B2 reference would receive null after having F2 assigning B1, right?

Please...help us on this!!!

Tks in advance!! ;-)
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no one?
 
Awishek sinha
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Felipe
I believe the answer should only be A as the relationship is unidirectional so the bar does not know anything about the foo it won't have a CMR feild getfoo() defined in the bar bean class..

Let me know if i am wrong..
 
neetika sharma
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Felipe,

I totaly agree with your understanding.
Even I think both A and B options are correct,
as the relationship is given one to one from both the side. So once b1 is assigned to f2,both f1 and b2 will loose there earlier assignments(because of the given one to one relationship) and become null.
[ September 10, 2007: Message edited by: Neetika Sood ]
 
Awishek sinha
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But this is unidirectional one to one relationship .. so in this case bar does not know anything about foo so i think it won't have a getfoo() cmr feild defined in bar bean class.
 
neetika sharma
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Awishek,

I think you have analysed it correctly. Statement is clearly telling, that it is a unidirectional one to one relationship.
Then, in this case both the B and C option will give errors.

Thanks for clarifying:-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic