Back to Browse

GRE Computer Science Question 27

2.0K views
Apr 2, 2012
1:59

27. Consider the following two fragments of Java programs. public void P1 (int x, int y, int z) { if ((x != 0) && ((y / x) == z)) z = z + 1; System.out.println("x = " + x + " y = " + y + " z = " + z); } public void P2 (int x, int y, int z) { if (((y / x) == z) && (x != 0)) z = z + 1; System.out.println("x = " + x + " y = " + y + " z = " + z); } Which of the following is true? (A) For all x, y, and z, P1(x, y, z) and P2(x, y, z) have the same behavior. (B) For all x and y, there exists z such that P1(x, y, z) and P2(x, y, z) behave differently. (C) For all x and z, there exists y such that P1(x, y, z) and P2(x, y, z) behave differently. (D) For all y and z, there exists x such that P1(x, y, z) and P2(x, y, z) behave differently. (E) For all x, y, and z, P1(x, y, z) and P2(x, y, z) behave differently.

Download

0 formats

No download links available.

GRE Computer Science Question 27 | NatokHD