ASU CSE 110 FINAL JAVA 2023 FINAL PAPER 2026 COMPLETE SOLUTIONS AND CORRECT ANSWERS GRADED, Exams of Java Programming

ASU CSE 110 FINAL JAVA 2023 FINAL PAPER 2026 COMPLETE SOLUTIONS AND CORRECT ANSWERS GRADED A+

Typology: Exams

2025/2026

Available from 01/28/2026

HighMark_Prep
HighMark_Prep 🇺🇸

5

(3)

27K documents

1 / 128

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASU CSE 110 FINAL JAVA 2023 FINAL
PAPER 2026 COMPLETE SOLUTIONS AND
CORRECT ANSWERS GRADED A+
44) Which of the following is considered a loop with a bound that
could be problematic?
a) for (i = 1; i != n; i++)
b) for (years = n; years < 0; years--)
c) for (i = 1; i <= n; i++)
d) for (int i = 1; i <= 10; i++). Answer: Answer: a) for (i = 1; i != n; i++)
45) In the __________ loop header, you can include multiple update
expressions, separated by commas, but it is not recommended.
a) do
b) while
c) for
d) do. Answer: Answer: b) while
46) What values does counter variable i assume when this loop
executes?
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download ASU CSE 110 FINAL JAVA 2023 FINAL PAPER 2026 COMPLETE SOLUTIONS AND CORRECT ANSWERS GRADED and more Exams Java Programming in PDF only on Docsity!

ASU CSE 110 FINAL JAVA 2023 FINAL

PAPER 2026 COMPLETE SOLUTIONS AND

CORRECT ANSWERS GRADED A+

⩥ 44) Which of the following is considered a loop with a bound that could be problematic? a) for (i = 1; i != n; i++) b) for (years = n; years < 0; years--) c) for (i = 1; i <= n; i++) d) for (int i = 1; i <= 10; i++). Answer: Answer: a) for (i = 1; i != n; i++) ⩥ 45) In the __________ loop header, you can include multiple update expressions, separated by commas, but it is not recommended. a) do b) while c) for d) do. Answer: Answer: b) while ⩥ 46) What values does counter variable i assume when this loop executes?

for (int i = 20; i >= 2; i = i - 6) { System.out.print(i + ","); } a) 20, 14, 8, 2 b) 20, 14, 8, 2, - 4 c) 20, 14, 8 d) 14, 8, 2. Answer: Answer: b) 20, 14, 8, 2, - 4 ⩥ 47) Insert a statement that will correctly terminate this loop when the end of input is reached. boolean done = false; while (!done) { String input = in.next(); if (input.equalsIgnoreCase("Q")) {


}

i++; } while (i < 5); a) abcd b) bcde c) bcbcd d) cdef. Answer: Answer: c) bcbcd ⩥ 49) What is the output of this code snippet if the user enters the numbers 1 2 3 4 - 1 5? double total = 0; boolean hasValidNumber = true; Scanner in = new Scanner(System.in); while (in.hasNextDouble() && hasValidNumber) { double input = in.nextDouble(); if (input < 0) { hasValidNumber = false; }

else { total = total + input; } } System.out.println(total); a) 15. b) 14. c) 12. d) 10.0. Answer: Answer: d) 10. ⩥ 50) What does the following code do? int sum = 0; final int count = 1000; for (int i = 1; i <= count; i++) { sum = sum + (int) (Math.random() * 101); } System.out.println(sum / count); a) It simulates the outcome of throwing a coin.

i--; } } System.out.println("r = " + r); a) 16. b) 128. c) 4096. d) 65536.0. Answer: Answer: d) 65536. ⩥ 52) Choose the loop that is equivalent to this loop. int n = 1; double x = 0; double s; do { s = 1.0 / (n * n); x = x + s; n++; } while (s > 0.01);

a) double x = 0; double s = 1; for (int k = 1; s > 0.01; k++) { s = 1.0 / (k * k); x = x + s; } b) double x = 0; double s = 1; for (int k = 1; k < 100; k++) { s = 1.0 / (k * k); x = x + s; } c) double x = 0; double s = 1; int k = 10; while (s > 0.01) {

int f1 = 0; int f2 = 1; int fRes; System.out.print(f1 + " "); System.out.print(f2 + " "); for (int i = 1; i < 10; i++) { fRes = f1 + f2; System.out.print(fRes + " "); f1 = f2; f2 = fRes; } System.out.println(); a) 0 1 5 7 9 11 13 15 17 19 b) 0 1 1 2 3 5 8 13 21 34 c) 0 1 4 6 8 10 12 14 16 18 d) 0 1 6 7 9 12 14 17 19 21. Answer: Answer: b) 0 1 1 2 3 5 8 13 21 34 ⩥ 54) How many times does the following loop execute?

double d; double x = Math.random() * 100; do { d = Math.sqrt(x) * Math.sqrt(x) - x; System.out.println(d); x = Math.random() * 10001; } while (d != 0); a) Exactly once b) Exactly twice c) Can't be determined d) Always infinite loop. Answer: Answer: c) Can't be determined ⩥ 55) What is the output of this loop? int i = 0; boolean found; while (i < 20 && !found) { int sum = i * 2 + i * 3;

a) 100 b) 49. c) 60. d) 10. Answer: Answer: a) 100 ⩥ 57) What does the following code snippet print? int a = 120; int b = 90; int n1 = Math.abs(a); int n2 = Math.abs(b); int result = 1; for (int k = 1; k <= n1 && k <= n2; k++) { if (n1 % k == 0 && n2 % k == 0) { result = k; } } System.out.println(result);

a) 10 b) 20 c) 30 d) 40. Answer: Answer: c) 30 ⩥ 58) What does the following code snippet display? char ch1 = '\ u0000'; char ch2 = '\ uffff'; for (int i = 0; i < 1000; i++) { if (i % 50 == 0) { System.out.println(); } System.out.print((char)(ch1 + Math.random() * (ch2 - ch1 + 1))); } a) It displays random Unicode characters. b) It displays random ASCII characters. c) Nothing because it has compilation error.

while (i < 10 && !found); c) int i = 0; while (i <= 10) { i++; } d) for (int i = 1; i <= 10; i++). Answer: Answer: d) for (int i = 1; i <= 10; i++) ⩥ 61) How many times does the following loop execute? for (double d = 1; d != 10; d++) { d = d / 3; System.out.print(d + " "); } a) 10 b) 9 c) 8

d) An infinite number of times. Answer: Answer: d) An infinite number of times ⩥ 62) How many times does the following loop execute? int i = 0; boolean found = false; while (i < 100 && !found) { i++; System.out.print(i + " "); int j = i * i; if ((i * i * i) % j == j) { found = true; } } a) 10 times b) 20 times c) 100 times d) An infinite number of times. Answer: Answer: c) 100 times

if (i % 2 == 0) { sum = sum + i; } } d) int sum; for (int i = 1; i <= n; i++) { sum = sum + i * 2;. Answer: Answer: b) int sum = 0; for (int i = 1; i <= n; i++) { sum = sum + i * 2; } ⩥ 64) Suppose that a program asks a user to enter multiple integers, either positive or negative, to do some calculation. The data entry will stop when the user enters a certain value to indicate the end of the data. What value should the code use as the sentinel? a) 0

b) - 1 c) 999 d) An alphabetic character. Answer: Answer: d) An alphabetic character ⩥ 65) Which of the following statements expresses why the following code is considered bad form? for (rate = 5; years-- > 0; System.out.println(balance))

... I. Unrelated expressions in loop header II. Doesn't match expected for loop idiom III. Loop iteration is not clear a) II and III only b) I and II only c) I and III only d) I, II, and III. Answer: Answer: d) I, II, and III ⩥ 66) Which of the following is considered a loop with a problematic condition? a) for(i = 1; i != n; i++)