Solutions to other chapters:
Java Methods A & AB:
Object-Oriented Programming and Data Structures
Answers and Solutions to Exercises
Chapter 6
1. |
(a) |
Invalid declaration of local variables: different types should be separated by a
semicolon, not a comma. |
|
(b) |
OK field |
2. |
(d) |
T -- it is often desirable to give the same name
to variables that hold the same types of values for
similar purposes in different methods. |
|
(e) |
F -- unfortunately the compiler assumes that the code
is correct and that the name refers to the local variable
where that variable is defined. |
11. |
|
double d = Math.sqrt((double)b * b - 4.0 * a * c);
double x1 = 0.5 * (-b - d) / a;
double x2 = 0.5 * (-b + d) / a;
|
12. |
|
Should be
double temp; |
|