For questions 3234 consider a class Foo that has two instanc

For questions 32-34 consider a class Foo that has two instance variables of type int. The values of these two instance variables may be assigned with the methods set1 (x) and set2 (x) where x is an int, . The values of the instance variables may be accessed through methods get 1 () and get2 (). Assume that y and z are object references for two separate instances of the class Foo. The following instructions are executed: y.set1(5); y.set2(6); y.set1(3); z.set2(y.get1()); y = z; The statement z. get2 (); will return 5 return 6 return 3 return 0 cause a run-time error The statement y. get2 (); will return 5 return 6 return 3 return 0 cause a run-time error If the instruction z. set2 (y .getl (}}; is executed, which of the following is true? (y = = z) is still true (y.getl() = = z.getl()) but (y.get2() != z.get2()) (y.getl() = = z.getl()) and (y.get2() = = z.get2()) but (y != z) (y.getl() = = z.get2()) and (y.get2() = = z.getl()) but (y != z) the statement causes a run-time error

Solution

Object y:
int1=5 //y.set1(5)
int2=6 //y.set2(6)

Object z:
int1=3 //z.set1(3)
int2=5 //z.set2(y.get1())

32) z.get2() will return 5 Ans: a

33) y.get2() will return 6 Ans: b

34) Given z.set2(y.get1())
y.get1() results 5
z.set2(5) results int2 of object z: 5

It means (y.get1()==z.get2() ) and (y.get2()!=z.get1())
Result: None of the given answer is true


  

 For questions 32-34 consider a class Foo that has two instance variables of type int. The values of these two instance variables may be assigned with the metho

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site