Win a copy of Microservices Testing (Live Project) this week in the Spring 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Wrong answer? HFE Page 432, question 4

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at
Unconfirmed error reports and comments from readers

for HFEJB.
reply
    Bookmark Topic Watch Topic
  • New Topic