apcsa 1.4
In the code segment below, assume that the int variables a and b have been properly declared and initialized. int c = a; int d = b; c += 3; d--; double num = c; num /= d; Which of the following best describes the behavior of the code segment?
B The code segment stores the value of (a + 3) / (b - 1) in the variable num.
Consider the following code segment. int a = 5; int b = 4; int c = 2; a *= 3; b += a; b /= c; System.out.print(b); What is printed when the code segment is executed?
C 9
Consider the following code segment. int a = 4; int b = 5; a++; b++; int c = a + b; a -= 1; System.out.println(a + c); What is printed when the code segment is executed?
D 15
Consider the following code segment, where k and count are properly declared and initialized int variables. k++; k++; count++; k--; count++; k--; Which of the following best describes the behavior of the code segment?
D The code segment leaves k unchanged and increases count by 2.
Consider the following code segment. num += num; num *= num; Assume that num has been previously declared and initialized to contain an integer value. Which of the following best describes the behavior of the code segment?
D The value of num is the square of twice its original value.
Consider the following code segment. int x = 5; x += 6 * 2; x -= 3 / 2; What value is stored in x after the code segment executes?
E 16