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

1.What is the output of the following code snippet? int s1 = 20; if (s1 <= 20) {

ID: 3678805 • Letter: 1

Question

1.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"); } Select one: a. 1 b. 2 c. 3 d. 123

2.

Which of the following conditions tests whether the user enters an integer value that will then be assigned to the floorvariable?

Select one:

a. if (in.nextInt(floor))

b. if (in.hasNextInt())

c. if (in.fail)

d. if (in.nextInt())

3.

Assuming that the user provides 49 as input, what is the output of the following code snippet?

Select one:

a. x: 0

b. x: 49

c. x: 50

d. There is no output due to compilation errors.

4.

Assuming that a user enters 45 as the brightness of a lamp, which of the following hand-trace tables is valid for the given code snippet?

Select one:

a.

b.

c.

d.

5.

Which of the following statements is true about the if statement?

Select one:

a. The if statement can have only one condition that evaluates to an integer value.

b. The if block is optional.

c. The else block is optional.

d. The if and else blocks should always be included within curly braces.

6.

Consider the following code snippet. What is the output?

Select one:

a. You need to practice!

b. Almost respectable !You hit triple digits!

c. You hit triple digits !Impressive!

d. Almost respectable !You hit triple digits !Impressive!

7.

Assuming that a user enters 50, 70, and 60 as input values one after another, separated by spaces, what is the output of the following code snippet?

Select one:

a. 0

b. 50

c. 60

d. 70

8.

What is the output of the following code snippet?

Select one:

a. Minimum salary requirement is not met.

b. Maximum salary limit is exceeded.

c. Salary requirement is met.

d. There is no output.

brightness description 0 "" 45 "pleasant" "dim"

Explanation / Answer

Question 1 --->Answer:d.123

Question 2 --->Answer:b.if (in.hasNextInt())

Question 3 --->Answer:b.x: 49

Question 4 --->Answer:a.

Question 5 --->Answer:c.The else block is optional.

Question 6 --->Answer:d. Almost respectable !You hit triple digits !Impressive!

Question 7 --->Answer:d. 70

Question 8 --->Answer:c.Salary requirement is met.