1. import java.util.*; 2. public class Test { 3. public static void main(String[] args) { 4. List strings = new ArrayList(); 5. // insert code here 6. } 7. } Which four, inserted at line 5, will allow compilation to succeed?()
AString s = strings.get(0);
BIterator i1 = strings.iterator();
CString[] array1 = strings.toArray();
DIterator i2 = strings.iterator();
EString[] array2 = strings.toArray(new String[1]);
FIterator i3 = strings.iterator();
相关问题推荐
-
Which method will complete this class?()
A、 public int compareTo(Object o){/* more code here */}
B、 public int compareTo(Score other){/* more code here */}
C、 public int compare(Score s1, Score s2){/* more code here */}
D、 public int compare(Object o1, Object o2){/* more code here */}
-
int x=0; int y 10; do { y--; ++x; } while (x
A、 5,6
B、 5,5
C、 6,5
D、 6,6
-
Which two are true about has-a and is-a relationships?()
AInheritance represents an is-a relationship.
BInheritance represents a has-a relationship.
CInterfaces must be used when creating a has-a relationship.
DInstance variables can be used when creating a has-a relationship.
-
package geometry; public class Hypotenuse { public InnerTriangle it = new InnerTriangle(); class InnerTriangle { public int base; public int height; } } Which is true about the class of an object that can reference the variable base? ()
A、 It can be any class.
B、 No class has access to base.
C、 The class must belong to the geometry package.
D、 The class must be a subclass of the class Hypotenuse.
-
class A { public A() { System.out.println(“hello from a”); } } class B extends A { public B () { System.out.println(“hello from b”); super(); } } public class Test { public static void main(String args[]) { A a = new B(); } } What is the result when main is executed?()
A、 Compilation fails.
B、 hello from a
C、 hello from b
D、 hello from b hello from a
E、 hello from a hello from b