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

Java MULTIPLE CHOICE. Choose the one alternative that best completes the stateme

ID: 3802995 • Letter: J

Question

Java

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question

20) What is 1.0+ 1.0+ 1.0+ 1.0+ 1.0== 5.0? 20) A) true B) false C) There is no guarantee that 1.0+ 1.0+ 1.0+ 1.0+ 1.0== 5.0 is true.
21) Analyze the following code.
boolean even= false; if (even) { System.out.println("It is even!"); }
21)
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; }
22)
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

20)A)true

21)B)The code displays nothing

because we defined even variable as false.whenever if gets executed it checks for true condition but even=false

so,if not executed.

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

it goes to infinite loop

23)c)long

24)c)-10

because x=0 it is not greater than 0 so condition failed.so,y takes value -10

25)B)11

Because of do while loop it gets executed one more time before it's value checked by while condition.

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