多选题 interface A { public int getValue() } class B implements A { public int getValue() { return 1; } } class C extends B { // insert code here } Which three code fragments, inserted individually at line 15, make use of polymorphism?()
public void add(C c) { c.getValue(); }
public void add(B b) { b.getValue(); }
public void add(A a) { a.getValue(); }
public void add(A a, B b) { a.getValue(); }
public void add(C c1, C c2) { c1.getValue(); }
单选题 String a = null; a.concat(“abc”); a.concat(“def”); System.out.println(a); What is the result?()
abc
null
abcdef
Compilation fails.
The code runs with no output.
An exception is thrown at runtime.
单选题 int x = 3; int y = 1; if (x = y) { System.out.println(“x = “ + x); } What is the result? ()
x=1
x=3
Compilation fails.
The code runs with no output. 
An exception is thrown at runtime.
多选题 public interface Foo { int k = 4; 3. } Which three are equivalent to line 2?()
final int k = 4;
public int k = 4;
static int k = 4;
abstract int k = 4;
volatile int k = 4;
protected int k = 4;
单选题 public class X { public static void main (Stringargs) { int a = new int [1] modify(a); System.out.printIn(a[0]); } public static void modify (int a) { a[0] ++; } } What is the result?()
The program runs and prints “0”
The program runs and prints “1”
The program runs but aborts with an exception.
An error “possible undefined variable” at line 4 causes compilation to fail.
An error “possible undefined variable” at line 9 causes compilation to fail.
多选题 ArraryList a = new ArrayList(); a.add(“Alpha”); a.add(“Bravo”): a.add(“Charlie”); a.add(“Delta”); Iterator iter = a.iterator(); Which two, added at line 17, print the names in the ArrayList in alphabetical order?()
for (int i=0; i< a.size(); i++) System.out.println(a.get(i)));
for (int i=0; i< a.size(); i++) System.out.println(a[i]);
while( iter.hasNext() ) System.out.println(iter.next()) ;
for (int i=0, i< a.size(); i++) System.out.println(iter[i]);
for (int i=0; i< a.size(); i++) System.out.println(iter.get(i));
多选题 class A { A() { } } class B extends A { } Which two statements are true?()
Class B’s constructor is public.
Class B’s constructor has no arguments.
Class B’s constructor includes a call to this().
Class B’s constructor includes a call to super().
多选题 public abstract class Shape { private int x; private int y; public abstract void draw(); public void setAnchor(int x, int y) { this.x = x; this.y = y; } } Which two classes use the Shape class correctly?()
public class Circle implements Shape { private int radius; }
public abstract class Circle extends Shape { private int radius; }
public class Circle extends Shape { private int radius; public void draw(); }
public abstract class Circle implements Shape { private int radius; public void draw(); }
public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }
单选题 static void test() { try { String x=null; System.out.print(x.toString() +“ “); } finally { System.out.print(“finally “); } } public static void main(String[] args) { try { test(); } catch (Exception ex) { System.out.print(”exception “); } } What is the result?()
null
finally
null finally
Compilation fails.
finally exception