B CORRECT 100%
Consider the following code segment, which is intended to calculate the average of two
quiz scores.
double avg = 15 + 20;
avg /= 2;
Which of the following best describes the behavior of the code segment? -
ANSWERConsider the following code segment, which is intended to calculate the
average of two quiz scores.
double avg = 15 + 20;
avg /= 2;
Which of the following best describes the behavior of the code segment?
Consider the following code segment.
int j = 10;
int k = 8;
j += 2;
k += j;
System.out.print(j);
System.out.print(" ");
System.out.println(k);
What is printed when the code segment is executed? - ANSWERE
12 20
Consider the following code segment.
double a = 7;
int b = (int) (a / 2);
double c = (double) b / 2;
System.out.print(b);
System.out.print(" ");
System.out.print(c);
What is printed as a result of executing the code segment? - ANSWERC
3 1.5
Consider the following code segment, which is intended to display 0.5.
int num1 = 5;
int num2 = 10;
double ans = num1 / num2;
System.out.print(ans);
Which of the following best describes the error, if any, in the code segment? -
ANSWERC