| CIT 591 Second Quiz Fall 2001, Dave Matuszek |
Name __________________________________________
|
i is an int variable and d is
a double variable. Answer each of the following eight questions
with YES or NO.
| Is this a syntax error? | Could this cause a runtime error? | |
i = 3.5 * d; |
||
d = 3.5 * i; |
||
i = (int) (3.5 * d); |
||
d = (double)(3.5 * i); |
0x77 0 04777
class Test {
public static void main(String args[]) {
int foo = 5;
foo(foo);
System.out.println(foo);
}
static void foo(int bar) {
System.out.println(bar++);
}
}
foo? foo? foo? (Besides int!) foo were
not declared static?System.out.print will print any object, but the result
may not be useful. What method must you define in order to control how
an object is printed?