Multiple choice technology programming languages

Given content-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? f2.setBar(f1.getBar());

  1. f1.getBar() ==null

  2. b2.getFoo == null

  3. b1.getFoo == null

  4. none of the above

Reveal answer Fill a bubble to check yourself
A,B Correct answer
Explanation

In a unidirectional relationship Foo→Bar, only Foo knows about Bar (Foo has a getBar() method, Bar has NO getFoo() method). After f2.setBar(f1.getBar()), f2 now points to b1. Since the relationship is unidirectional from Foo to Bar, b1 has NO reference to any Foo. b1.getFoo() doesn't exist (not that it's null - the method doesn't exist). For the unidirectional case, b2.getFoo() also doesn't exist - but the question implies b2 now has no incoming reference from f2.