viewing paste Unknown #27586 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
Assume you have defined a Dog class that has a String name member and corresponding mutator and accessor.  Also, assume you did not define a toString() method for your Dog class.
 
Two Dog references, myDog and yourDog, are declared, and one of them, yourDog, is used to instantiate a Dog object (code not shown).   Next, the following statement is executed:
 
   myDog = yourDog;
so that both references manage (i.e., point to) the same Dog object.
 
If we change myDog's name, by a mutator call:
 
   myDog.setName("LiliKoi");
this will (choose all true statements):
 
 
 
    A.  cause both
   System.out.println( myDog );
and
 
   System.out.println( yourDog );
to display LiliKoi.
 
    B.  cause only
   System.out.println( yourDog.getName() );
to display LiliKoi, but not
 
   System.out.println( myDog.getName() );
    C.  cause only
   System.out.println( myDog.getName() );
to display LiliKoi, but not
 
   System.out.println( yourDog.getName() );
    D.  cause both
   System.out.println( myDog.getName() );
and
 
   System.out.println( yourDog.getName() );
to display LiliKoi.
Viewed 1075 times, submitted by Guest.