单项选择题
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 -
多项选择题
Whichofthefollowingstatementsaboutvariablesandtheirscopesaretrue?()
A. Instance variables are member variables of a class.
B. Instance variables are declared with the static keyword.
C. Local variables defined inside a method are created when the method is executed.
D. Local variables must be initialized before they are used. -
单项选择题
Given the uncompleted code of a class: class Person { String name, department; int age; public Person(String n){ name = n; } public Person(String n, int a){ name = n; age = a; } public Person(String n, String d, int a) { // doing the same as two arguments version of constructor // including assignment name=n,age=a department = d; } } Which expression can be added at the "doing the same as..." part of the constructor?()
A. Person(n,a);
B. this(Person(n,a));
C. this(n,a);
D. this(name,age);
