Consider the code that follows and answer the questions below. Hint: Trace the program from the main
Question:
Consider the code that follows and answer the questions below.
Hint: Trace the program from the main method to find the answers.
public class Driver { private static int x, y, z; private static double a; public static void main (String [] args) { resetValues(); y += x++; System.out.println("a: " + a + " x: " + x + " y: " + y + " z: " + z); resetValues(); z = y++ % ++x; System.out.println("a: " + a + " x: " + x + " y: " + y + " z: " + z); resetValues(); a = (x * y) / 2; System.out.println("a: " + a + " x: " + x + " y: " + y + " z: " + z); } public static void resetValues() { x = 3; y = 5; z = 14; a = 0.0; } }
What would be displayed by the first println?
What would be displayed by the second println?
What would be displayed by the third println?
College Algebra With Modeling And Visualization
ISBN: 9780134418049
6th Edition
Authors: Gary Rockswold