Java Reference
In-Depth Information
public
String toString()
{
return ("Stock Name: " + name
+ "\r\n Previous Price: " + previousPrice
+ "\r\n Closing Price: " + closingPrice
+ "\r\n Number Of Shares: " + numberOfShares);
}
}
Chapter 9
1. a. True; b. True; c. True; d. True; e. False; f. False; g. True
3. a. This declaration is correct.
b. The final declaration should be:
final int
SIZE
¼
100;
c. This declaration should be:
int
[] numList =
new int
[10]
d. This declaration is correct.
e. This declaration should be:
double[]
scores
¼
new double
[50];
5. 0 to 49
7.
-3 -1 1 3 5
5-183-1
9. a.
funcOne(list, 50);
b.
System.out.print(funcSum(50, list[3]));
c.
System.out.print(funcSum(list[29], list[9]));
d.
funcTwo(list, Alist);
11. The elements of
list
are:
5, 6, 9, 19, 23, 37
13.
One contains: 3 8 13 18 23
Two contains: 5 15 25 35 45 28 33 38 43 48
15.
for
(
int
i = 1; i < 9; i++)
if
(scores[i] > scores[i + 1])
System.out.println(i + " and " + (i + 1)
+ " elements of scores are out of order.");
17.
a. Valid
b. Invalid
c. Invalid
d. Valid
19.
0 -2
1 6
2 -12
3 1
4 13
21.
a. Valid
b. Valid
c. Invalid
d. Valid
Search WWH ::
Custom Search