Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programing multiple choice 15) What is sum after the following loop termina

ID: 3837805 • Letter: J

Question

Java Programing multiple choice

15) What is sum after the following loop terminates?
int sum = 0; int item= 0; do { item++; sum += item; if (sum > 4) break; } while (item < 5);

A) 6 B) 8 C) 7 D) 5

21) Analyze the following code.
boolean even= false; if (even) { System.out.println("It is even!"); }

A) The code is wrong. You should replace if (even) with if (even = true) B) The code displays nothing. C) The code is wrong. You should replace if (even) with if (even == true) D) The code displays It is even!

22) Analyze the following fragment: double sum= 0; double d= 0; while (d != 10.0) { d+= 0.1; sum += sum + d; }

A) The program does not compile because sum and d are declared double, but assigned with integer value 0. B) The program never stops because d is always 0.1 inside the loop. C) After the loop, sum is 0 + 0.1+ 0.2+ 0.3+ ... + 1.9 D) The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers. 23) Which of these data types requires the most amount of memory?

23) A) byte B) int C) long D) short 4 24) What is y after the following statement is executed? x= 0; y= (x > 0) ? 10 :-10; 24) A) 0 B) 20 C) -10 D) 10 E) Illegal expression

25) How many times will the following code print "Welcome to Java"? int count= 0; do { System.out.println("Welcome to Java"); } while (count++ < 10);

25) A) 8 B) 11 C) 10 D) 0 E) 9

Explanation / Answer

15)
sum =
1 2 3
6

21)
B) The code displays nothing.

22)
D) The program may not stop because of the phenomenon referred to as numerical inaccuracy for operating with floating-point numbers.

23)
   C) long => 64 bytes
24)
C) -10 => cinditional operator

25)
B) 11 => print for count = 0 to 10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote