This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Wrong answer? HFE Page 432, question 4 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Reply Bookmark "Wrong answer? HFE Page 432, question 4" Watch "Wrong answer? HFE Page 432, question 4" New topic
Author

Wrong answer? HFE Page 432, question 4

Hai Lin
Ranch Hand

Joined: May 23, 2004
Posts: 79
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 ]
alzamabar
Ranch Hand

Joined: Jul 24, 2002
Posts: 379
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
alzamabar
Ranch Hand

Joined: Jul 24, 2002
Posts: 379
Originally posted by Marco Tedone:


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, but, that said, I think that answer B was not correct too.

Dan T
Ranch Hand

Joined: Jun 15, 2004
Posts: 66
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 ]


This is because every Foo can only have 1 Bar, and every Bar can only have 1 Foo. Thus, if u set B1 to F2, F2 will not have relatioship with B2 because F2 can only refer to 1 Bar, which is B1. Now, B2 refers to nothing.
Lionel Orellana
Ranch Hand

Joined: Mar 19, 2004
Posts: 87
Have a look at
Unconfirmed error reports and comments from readers

for HFEJB.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wrong answer? HFE Page 432, question 4
 
Similar Threads
HFEJB - question page 426 - # 4.
Entity beans relationships question in the HFE
Doubt in Entity Bean Relationship
HFE page 426
QNo. 4 Ch-6 Coffee Cram Mock Exam!!