Originally posted by Hai Lin:
Hi, guys,
Feel big doubt for the HFE page 432, question 4
Given 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 runs? (Choose all the that apply.)
f2.setBar(f1.getBar());
A. f1.getBar() == null
B. b2.getFoo() == null
C. b1.getFoo() == null
D. none of the above
the answer given by the book is A, B. Actually, why B is correct? Since the Foo and Bar are unidirectional relationship, that mean, foo can getBar(), but bar cannot get Foo, there should NOT have method like b2.getFoo() existing.
Thanks a lot for your advice.
Hai
[ August 12, 2004: Message edited by: Hai Lin ]
Actually, although your observation is *logically* true, there is nothing in the specs that say that you can't go from Bar to Foo. I'm referring to chapter '10.3.7.2 One-to-one unidirectional relationships', page 138.
It would be interesting to hear from the author (or co-authors) the explanation to this question.
Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD