Java Reference
In-Depth Information
sum += temps[i];
}
System.out.println(“Average: “ + (sum / i));
}
}
Which statement contains an error?
a.
for (i = 0; i < arguments.length & i < 10; i++) {
b.
sum += temps[i];
c.
System.out.println(“Average: “ + (sum / i));
d.
None; the program is correct.
The answer is available on the topic's website at
http://www.java21days.com.
Visit the
Day 7 page and click the Certification Practice link.
To extend your knowledge of the subjects covered today, try the following exercises:
1.
Modify the
PrimeFinder
class so that it throws a new exception,
NegativeNumberException
, if a negative number is sent to the constructor.
2.
Modify the
PrimeThreads
application so that it can handle the new
NegativeNumberException
error.
Where applicable, exercise solutions are offered on the topic's website at
http://www.