Consider the following code segment and determine the output
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:
Solution
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
