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

If you have a $30 and have a 15% discount whats the cost
Mrs. Decker saw three witches land in a field where they found a pile of pumpkins and a ghost. They agree to sleep overnight in the field and divide up the pil
3a^3x(4a^2bcx^3) how do I solve this problem
17.9, ?, 16.5, 35.90
A biased coin has a probability p = 0.44 of landing heads. The number of times heads appears when the coin is tossed twice is represented by X. Which graph show
Margaret said that she use the distributive property to solve 4×444 is there is her answer correct
the ratio of red proms to yellow pome on a float is 5 to 7.if there are 392 yellows poms on a float, how many red poms are there
Determine the value of x in the diagram below.
How can i talk to jacob sartorius?
write a metaphor about someone who is stubborn