carriganlee1375 carriganlee1375
  • 25-01-2021
  • Computers and Technology
contestada

What is the output of the following code snippet? int s1 = 20; if (s1 <= 20) { System.out.print("1"); } if (s1 <= 40) { System.out.print("2"); } if (s1 <= 20) { System.out.print("3"); }

Respuesta :

MrRoyal
MrRoyal MrRoyal
  • 25-01-2021

Answer:

The program outputs 123

Explanation:

The first line of the program initializes s1 to 20

The second line checks if s1 is less than or equal to 20.

This is true,

So, 1 is printed

The third line checks if s1 is less than or equal to 40.

This is true,

So, 2 is printed

The fourth line checks if s1 is less than or equal to 20.

This is true,

So, 3 is printed

Hence, the output is 123

Answer Link

Otras preguntas

what did captain hook say in the bakery
what is the setting of the story? for reading exit ticket
Tim is thinking of two numbers. The quotient of the two numbers is 9. The difference of the two numbers is 48. The sum of the two numbers is 60. What are the tw
the reaction where heat is added is called? removed?
write 336 mi in 11.2 h as a rate in simplest form.
Which of the following is the leading source of income for panamá?
the two bases of an isosceles trapezoid are 12 and 20 feet long, respectively. find the rate at which the area is changing when the equal sides are 5 feet long
who was grendel, and did he do to terrorize the danes ?
if cos a = 1/3 then the positive value of tan 1/2a is? i did radical 2/3 over 4/3, but im not sure what to do now.
do the greatest sign point toward the greater number