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

The graph shows the relationship between the total cost and the number of gift cards that Raj bought for raffle prizes. What would be the cost for 5 of the gift
Point A is located at ​(4, 8)​ and point B is located at ​(14, 10)​ . What point partitions the directed line segment ​ AB¯¯¯¯¯ ​ into a 1:3 ratio? (6 1/2, 8
suppose y varies directly with x. if y= 24 when x = 4, what is y when x = 9?
I need help please this due tomorrow
As a part of a contest, a store is giving a special prize if a contestant can roll 3 standard six-sided number cubes, and get the same number on each. What is t
what is ten times twelve
4 - 2x = 10 A) -7 B) -3 C) 0 D) 3
What element has the greatest number of valence electrons available for bonding? Selenium. Boron. Calcium. Chlorine.
can someone please help with this problem
Subject + _________ +Present tense of être + Past Participle Reflexive Pronoun Subject Pronoun Reflexive Verb Interrogative expression