Consider the following code segment and determine the output for various values
ID: 3935096 • Letter: C
Question
Consider the following code segment and determine the output for various values of k and j (assume k and j are int variables declared and initialized somewhere before this segment):
if( k <= j)
System.out.println("Huey");
else
System.out.println("Dewey");
System.out.println("Louie");
a. if k == 10 and j == 12 the output is:
b. if k == 22 and j == 15 the output is:
c. if j and k are both 15 the output is:
Explanation / Answer
a. if k == 10 and j == 12 the output is:
10<=12 is true
output is :
Huey
Louie
b. if k == 22 and j == 15 the output is:
here k<=j is false
output:
Dewey
Louie
c. if j and k are both 15 the output is
Huey
Louie
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.