| CIT 591 Midterm Exam, Fall 2008 | Name ______________________________ |
for loop to print the numbers 1 through 100, one number per
line.while loop to print the numbers 1 through 100, one number
per line.do-while loop to print the numbers 1 through 100, one number
per line. switch statement to print even if the int variable
number is even, or odd if number is odd. IllegalArgumentException if
the variable n is greater than 9999. (IllegalArgumentException is a Sun-provided class.) double values.
int values?Payroll class,
tell whether it should be static, instance, or local.Person must have a name.
Every Employee (which extends
Person) must have an integer employeeID. Write
a minimal constructor for Employee. toString() method.
equals(Object obj) method.
main method.
@Before method.
@Before method is run
once for each @Test method.
double parameter,
it can be called with an int value.
double parameter,
it can be called with a char value.
x = x++; adds one to x. |
The variable "Even" must be declared outside the block. The fact that it is capitalized is poor style, but is not a syntax error. |
| Correct Answers | True but irrelevant statements |
|---|---|
|
|
System.out.print(1 + 2 + "buckle my shoe" + 3 + 4 + "close
the door");System.out.print("hello".length() == 5 ? "yes" : "no"); yes
System.out.print(new char[] { 'a', 'b', 'c' }); abc int x; System.out.print(x = 5 + 7 * 2); 19
char[] chs = new char[] { 'a', 'b', 'c' }; System.out.print(chs[1]); b
int[ ][ ] foo = new int[ ][ ] { { 3, 1, 4
}, {1, 5, 9 }, { 2, 6 } };
|
|||
|
|||
|
public and private for
variables declared inside a method? Why or why not? isLetter(char ch)?isLetter method? trim()?trim method? assert statement that says you believe the variable
difference to be zero. catch an Exception e. Write a statement to print
out all available information about e.