Given the following code:
public class Person{
int arr[] = new int[10];
public static void main(String a[]) {
System.out.println(arr[1]);
}
}
Which statement is correct?()
A. When compilation some error will occur.
B. It is correct when compilation but will cause error when running.
C. The output is zero.
D. The output is null.
您可能感兴趣的试卷
你可能感兴趣的试题
Given the following code:
public class Person{ static int arr[] = new int[10];
public static void main(String a[]) {
System.out.println(arr[1];)
}
}
Which statement is correct?()
A. When compilation some error will occur.
B. It is correct when compilation but will cause error when running.
C. The output is zero.
D. The output is null.
A. The bytecode verifier loads all classes needed for the execution of a program.
B. Executing code is performed by the runtime interpreter.
C. At runtime the bytecodes are loaded, checked and run in an interpreter.
D. The class loader adds security by separating the namespaces for the classes of the local file system from those imported from network sources.
Given the following code fragment:
1) String str = null;
2) if ((str != null) && (str.length() > 10)) {
3) System.out.println("more than 10");
4) }
5) else if ((str != null) & (str.length() < 5)) {
6) System.out.println("less than 5");
7) }
8) else { System.out.println("end"); }
Which line will cause error?()
A. line 1
B. line 2
C. line 5
D. line 8
A. public
B. no modifier
C. protected
D. private
A. Local variables defined inside a method are destroyed when the method is exited.
B. Local variables are also called automatic variables.
C. Variables defined outside a method are created when the object is constructed.
D. A method parameter variable continues to exist for as long as the object is needed in which the method is defined.
Given the following code:
1) public void modify() {
2) int i, j, k;
3) i = 100;
4) while ( i > 0 ) {
5) j = i * 2;
6) System.out.println (" The value of j is " + j );
7) k = k + 1;
8) i--;
9) }
10) }
Which line might cause an error during compilation?()
A. line 4
B. line 6
C. line 7
D. line 8
A. The description of the class and its purpose
B. A list of methods in its super class
C. A list of member variable
D. The class hierarchy
A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.
B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.
C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.
D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.
Given the following code:
public class Test {
void printValue(int m){
do {
System.out.println("The value is"+m);
}
while( --m > 10 )
}
public static void main(String arg[]) {
int i=10;
Test t= new Test();
t.printValue(i);
}
}
Which will be output?()
A. The value is 8
B. The value is 9
C. The value is 10
D. The value is 11
public void test() {
try { oneMethod();
System.out.println("condition 1");
}
catch (ArrayIndexOutOfBoundsException e) {
System.out.println("condition 2");
}
catch(Exception e) {
System.out.println("condition 3");
}
finally {
System.out.println("finally");
}
}
Which will display if oneMethod run normally?()
A. condition 1
B. condition 2
C. condition 3
D. finally
最新试题
Which statement is true about the set variable on line 12?()
What is the result?()
What is the output if the main() method is run?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()
Which statement is true?()
Given: foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait(). From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()
What is the result?()
What is the result?()
What is the result?()
Which code, inserted at line 4, guarantees that this program will output [1, 2]?()