Author | Topic: Barry Boones Mock Exam newtest.html |
Jerson Chua ranch hand |
posted April 02, 2000 12:11 AM
Select all valid answers. String[][] s = new String[10][]; b) s is a two-dimensional array containing 10 rows and 10 columns c) s is an array of 10 arrays. d) Each element in s is set to "" e) Each element in s is uninitialized and must be initialized before it is referenced. The answer given is c but I think the answer should include e. Why? You can find this mock exam at since is not working.
|
Milind ranch hand |
posted April 02, 2000 07:21 AM
Basically a two diamensional array is an array of arrays (nested array) in java. So option C is correct. Any array can be declared and constructed in a single line as follows: String[][] s = new String[10][]; When an array is constructed, its elements are automatically initialized exactly as for object member variable. So the option E is incorrect. Numerical elements are initialized to zero, boolean to false and object refrences to null.
|
maha anna bartender |
posted April 02, 2000 09:46 AM
Jerson, Here is my reasoning for each ans a) This line of code is illegal. No, It is legal b) s is a two-dimensional array containing 10 rows and 10 columns c) s is an array of 10 arrays. d) Each element in s is set to "" e) Each element in s is uninitialized and must be initialized before it is referenced. regds [This message has been edited by maha anna (edited April 02, 2000).]
|
Jerson Chua ranch hand |
posted April 02, 2000 07:20 PM
thanks millind and maha anna.
|
| | |