public class Test{
public static void main( String[] argv ){
// insert statement here
}
}
Which statement, inserted at line 3, produces the following output?()
Exception in thread “main” java.lang.AssertionError: true at Test.main(Test.java:3)
A. assert true;
B. assert false;
C. assert false : true;
D. assert false == true;
E. assert false: false;
您可能感兴趣的试卷
你可能感兴趣的试题
public class Delta {
static boolean foo(char c) {
System.out.print(c);
return true;
}
public static void main( String[] argv ) {
int i =0;
for ( foo(‘A’); foo(‘B’)&&(i<2); foo(‘C’)){
i++ ;
foo(‘D’);
}
}
}
What is the result?()
A. ABDCBDCB
B. ABCDABCD
C. Compilation fails.
D. An exception is thrown at runtime.
class A {
protected int method1(int a, int b) { return 0; }
}
Which two are valid in a class that extends class A?()
A. public int method1(int a, int b) { return 0; }
B. private int method1(int a, int b) { return 0; }
C. private int method1(int a, long b) { return 0; }
D. public short method1(int a, int b) { return 0: }
E. static protected int method1(int a, int b) { return 0; }
package test1;
public class Test1 {
static int x = 42;
}
package test2;
public class Test2 extends test1.Test1 {
public static void main(String[] args) {
System.out.println(“x = “ + x);
}
}
What is the result?()
A. x = 0
B. x = 42
C. Compilation fails because of an error in line 2 of class Test2.
D. Compilation fails because of an error in line 3 of class Test1.
E. Compilation fails because of an error in line 4 of class Test2.
public interface Foo {
int k = 4; 3. }
Which three are equivalent to line 2?()
A. final int k = 4;
B. public int k = 4;
C. static int k = 4;
D. abstract int k = 4;
E. volatile int k = 4;
F. protected int k = 4;
public class Test {
public static void aMethod() throws Exception {
try {
throw new Exception();
} finally {
System.out.println(“finally”);
}
}
public static void main(String args[]) {
try {
aMethod();
} catch (Exception e) {
System.out.println(“exception”);
}
System.out.println(“finished”);
}
}
What is the result?()
A. finally
B. exception finished
C. finally exception finished
D. Compilation fails.
int x = 3;
int y = 1;
if (x = y) {
System.out.println(“x = “ + x);
}
What is the result? ()
A.x=1
B.x=3
C.Compilation&ensp;fails.
D.The&ensp;code&ensp;runs&ensp;with&ensp;no&ensp;output.&ensp;
E.An&ensp;exception&ensp;is&ensp;thrown&ensp;at&ensp;runtime.
A. public
B. private
C. protected
D. transient
E. default access
int i = 1,j = 10;
do {
if(i>j) {
break;
}
j--;
} while (++i <5);
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 A {
A() { }
}
class B extends A {
}
Which two statements are true?()
A. Class B’s constructor is public.
B. Class B’s constructor has no arguments.
C. Class B’s constructor includes a call to this().
D. Class B’s constructor includes a call to super().
interface Animal {
void soundOff();
}
class Elephant implements Animal {
public void soundOff() {
System.out.println(“Trumpet”);
}
}
class Lion implements Animal {
public void soundOff() {
System.out.println(“Roar”);
}
}
class Alpha1 {
static Animal get( String choice ) {
if ( choice.equalsIgnoreCase( “meat eater” )) {
return new Lion();
} else {
return new Elephant();
}
}
}
Which compiles?()
A. new Animal().soundOff();
B. Elephant e = new Alpha1();
C. Lion 1 = Alpha.get(“meat eater”);
D. new Alpha1().get(“veggie”).soundOff();
最新试题
What is the appropriate definition of the hashCode method in class Person?()
Which two of statements are true?()
Which two statements are true?()
Which statement is true?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()
Which two are possible results?()
Which statement is true?()
Which statement is true about the set variable on line 12?()
Given that t1 is a reference to a live thread, which is true?()
What is the result?()