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

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

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