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

Summarize the U.S military interactions with the Native Americans
How do I solve this
Match the battle names to the locations where they were fought. El Alamein Pearl Harbor Stalingrad Midway Guadalcanal
4. What happened to the Industrial Workers of the World (IWW) because of U.S. involvement in World War I?
Need helppppp asapppppppppp
Borgir? Plz answer, I'll give brainliest...
accurately calculating the rate at which a particular drug will enter or leave the body is... A. possible B. easy C. difficult
SOCORRO! Assinale a alternativa que apresenta erro de colocação pronominal: * 1 ponto a) Você não devia calar-se. b) Não lhe darei qualquer informação. c) O fil
please help with math!! geometry explain if you can :)
XYZ Co. reported the following results for October: Sales $ 32,000 Cost of goods sold (all variable) $ 6,000 Total variable selling expense $ 2,500 Total fixed