Based on the dangling-else discussion, state the output for each of the following code segments when x is 9 and y is 11 and when x is 11 and y is 9. We eliminated the indentation from the following code to make the problem more chal- lenging. [Hint: Apply the indentation conventions you’ve learned.]

```
if (x < 10)
if (y > 10)
System.out.println("*****");
else
System.out.println("#####");
System.out.println("$$$$$");
```


```
When: x = 9, y = 11
*****
$$$$$

When: x = 11, y = 9
$$$$$
```

Computer Science & Information Technology

You might also like to view...

What is the default value for the GridBagConstraint fill?

a. NONE. b. BOTH. c. CENTER. d. HORIZONTAL.

Computer Science & Information Technology

What command in the Windows 10 CLI will display the contents of a text file on the standard output device?

A. TYPE B. PRINT C. ASSOC D. XCOPY

Computer Science & Information Technology

An __________ allows selection of a contiguous range of items in the list.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

What is y displayed in the following code?

``` public class Test1 { public static void main(String[] args) { int x = 1; int y = x = x + 1; System.out.println("y is " + y); } } ``` a. y is 0. b. y is 1 because x is assigned to y first. c. y is 2 because x + 1 is assigned to x and then x is assigned to y. d. The program has a compile error since x is redeclared in the statement int y = x = x + 1.

Computer Science & Information Technology