READ Free Dumps For Oracle- 1z0-803
Question ID 21919 | Given:
public class ScopeTest {
int z;
public static void main(String[] args){
ScopeTest myScope = new ScopeTest();
int z = 6;
System.out.println(z);
myScope.doStuff();
System.out.println(z);
System.out.println(myScope.z);
}
void doStuff() {
int z = 5;
doStuff2();
System.out.println(z);
}
void doStuff2() {
z=4;
}}
What is the result?
|
Option A | Explanation:
Within main z is assigned 6. z is printed. Output: 6
Within doStuff z is assigned 5.DoStuff2 locally sets z to 4 (but MyScope.z is set to 4), but in Dostuff z is still 5. z
is printed. Output: 5
Again z is printed within main (with local z set to 6). Output: 6 Finally MyScope.z is printed. MyScope.z has
been set to 4 within doStuff2(). Output: 4
|
Correct Answer | A |
Explanation
Question ID 21920 | Which two are valid instantiations and initializations of a multi dimensional array?
|
Option A | int [] [] array 2D = { { 0, 1, 2, 4} {5, 6}};
|
Option B | int [] [] array2D = new int [2] [2];
array2D[0] [0] = 1;
array2D[0] [1] = 2;
array2D[1] [0] = 3;
array2D[1] [1] = 4;
|
Option C | int [] [] [] array3D = {{0, 1}, {2, 3}, {4, 5}};
|
Option D | int [] [] [] array3D = new int [2] [2] [2];
array3D [0] [0] = array;
array3D [0] [1] = array;
array3D [1] [0] = array;
array3D [0] [1] = array;
|
Option E | int [] [] array2D = {0, 1};
|
Correct Answer | B,D |
Explanation Explanation: In the Java programming language, a multidimensional array is simply an array whose components are themselves arrays.