int i = 1,j = 10;
do{
if (i>j) {
continue;
}
j--;
} while (++i <6);
System.out.println(“i = “ +i+” and j = “+j);
What is the result?()
A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 4
D. i = 5 and j = 6
E. i = 6 and j = 6
您可能感兴趣的试卷
你可能感兴趣的试题
class Super {
public int i = 0;
public Super(String text) {
i = 1;
}
}
public class Sub extends Super {
public Sub(String text) {
i = 2;
}
public static void main(String args[]) {
Sub sub = new Sub(“Hello”);
System.out.println(sub.i);
}
}
What is the result?()
A. 0
B. 1
C. 2
D. Compilation fails.
class A {
}
class Alpha {
private A myA = new A();
void dolt( A a ) {
a = null;
}
void tryIt() {
dolt( myA );
}
}
Which two statements are correct?()
A. There are no instanced of A that will become eligible for garbage collection.
B. Explicitly setting myA to null marks that instance to be eligible for garbage collection.
C. Any call on tryIt() causes the private instance of A to be marked for garbage collection.
D. Private instances of A become eligible for garbage collection when instances of Alpha become eligible for garbage collection.
public class Test {
public static void main(String Args[]) {
int i =1, j = 0;
switch(i) {
case 2: j +=6;
case 4: j +=1;
default: j +=2;
case 0: j +=4;
}
System.out.println(“j =” +j);
}
}
What is the result? ()
A. 0
B. 2
C. 4
D. 6
E. 9
F. 13
int i = 0, j = 5;
tp;
for (;;) {
i++;
for(;;) {
if (i> --j) {
break tp;
break tp;
}
}
System.out.println(“i=” +i “,j =”+j);
}
What is the result?()
A. i = 1, j = 0
B. i = 1, j = 4
C. i = 3, j = 4
D. i = 3, j = 0
E. Compilation fails.
public void foo( boolean a, boolean b ){
if( a ) {
System.out.println( “A” );
} else if ( a && b ) {
System.out.println( “A&&B” );
} else { 17. if ( !b ) {
System.out.println( “notB” );
} else {
System.out.println( “ELSE” );
}
}
}
What is correct?()
A. If a is true and b is true then the output is “A&&B”.
B. If a is true and b is false then the output is “notB”.
C. If a is false and b is true then the output is “ELSE”.
D. If a is false and b is false then the output is “ELSE”.
public class Foo {
public void main( String[] args ) {
System.out.println( “Hello” + args[0] );
}
}
What is the result if this code is executed with the command line?()
A. Hello
B. Hello Foo
C. Hello world
D. Compilation fails.
E. The code does not run.
1. public class OuterClass {
2. private double d1 = 1.0;
3. // insert code here
4. }
Which two are valid if inserted at line 3?()
A. static class InnerOne { public double methoda() { return d1; } }
B. static class InnerOne { static double methoda() { return d1; } }
C. private class InnerOne { public double methoda() { return d1; } }
D. protected class InnerOne { static double methoda() { return d1; } }
E. public abstract class InnerOne { public abstract double methoda(); }
1. public class ReturnIt {
2. return Type methodA(byte x, double y) {
3. return (long)x / y * 2;
4. }
5. }
What is the narrowest valid returnType for methodA in line2?()
A. int
B. byte
C. long
D. short
E. float
F. double
public class Test {
public static void main(String[] args) {
int x = 0;
assert (x > 0) ? “assertion failed” : “assertion passed”;
System.out.println(“Finished”);
}
}
What is the result?()
A. finished
B. Compilation fails.
C. An AssertionError is thrown and finished is output.
D. An AssertionError is thrown with the message “assertion failed”.
E. An AssertionError is thrown with the message “assertion passed”.
public class X {
public static void main(String [] args) {
try {
badMethod();
System.out.print(“A”);
}
catch (RuntimeException ex) {
System.out.print(“B”);
}
catch (Exception ex1) {
System.out.print(“C”);
}
finally {
System.out.print(“D”);
}
System.out.print(“E”);
}
public static void badMethod() {
throw new RuntimeException();
}
}
What is the result?()
A. BD
B. BCD
C. BDE
D. BCDE
E. ABCDE
F. Compilation fails.
最新试题
Which two are possible results?()
Which code, inserted at line 4, guarantees that this program will output [1, 2]?()
Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()
What is the result?()
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
What can be a result?()
What is the result?()
Which statement is true?()
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 three changes should be made to adapt this class to be used safely by multiple threads?()