Can someone give explnation on how to find answer of below q

Can someone give explnation on how to find answer of below questions

For questions 32-34 consider a class Foo that has two instance variables of type int. The values of these two instance vaiables may be assigned with the methods set1(x) and set2(x) where x is an int,·The values ofthe instance variables may be accessed through methods get 1 and get2( ). Assume taty and z are object references for two separate instances of the class Foo· The following instructions are executed: y.setl (5) y.set2 (6) z.setl (3) z.set2 (y.getl ()); y = z; 32) The statement z.get2) will a) retun!5 b) retum 6 c) retun.3 d) retun O e) cause a run-time eror 33) The statement y.get2: will a) return!5 b) retun 6 c) retun3 d) retum 0 e) cause a run-time error 34)If the instruction z.set2 (y.getl) is executed, which of the following is true? a) (y== z)is still tue c) (y.getl()-=z.getl( )) and G.get2( ) ==z.get2( )) but (y != z) d) (y.getl( )-z.get2( )) and (y.get2( )-z. get IO) but (y != z) e) the statement causes a rm-time error

Solution

32)

a)return 5 //y.get1() returns 5 which is passed to z.set2(5) so z.get2() returns 5

33)

b)return 6 //y.set2(6) which sets x value 6 so y.get2 returns the x value which is 6

34)

d)(y.get1()==z.get2()) and (y.get2()!=z.get1()) but (y!=z)

35) Will randomly assign an integer between 1 and n (inclusive) to side //please remove side=1; in getSide method


36)

d) n and side only

37)roll and getSide methods   

Can someone give explnation on how to find answer of below questions For questions 32-34 consider a class Foo that has two instance variables of type int. The v

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site