多选题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

题目
多选题
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?()
A

String s = strings.get(0);

B

Iterator i1 = strings.iterator();

C

String[] array1 = strings.toArray();

D

Iterator i2 = strings.iterator();

E

String[] array2 = strings.toArray(new String[1]);

F

Iterator i3 = strings.iterator();

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

1. public class A {  2. void A() {  3. System.out.println(“Class A”);  4. }  5. public static void main(String[] args) {  6. new A();  7. }  8. }  What is the result?()  

  • A、 Class A
  • B、 Compilation fails.
  • C、 An exception is thrown at line 2.
  • D、 An exception is thrown at line 6.
  • E、 The code executes with no output.

正确答案:E

第2题:

1. import java.util.*;  2. class ForInTest {  3. static List list = new ArrayList();  4.  5. static List getList() { return list; }  6.  7. public static void main(String [] args) {  8. list.add("a"); list.add("b"); list.add("c");  9. // insert code here  10. System.out.print(o);  11. }  12. } 第 9 行插入哪一项将输出 abc?() 

  • A、for(char o: list)
  • B、for(Object o: getList())
  • C、for(Object o: getList();)
  • D、for(Object o: o.getList())

正确答案:B

第3题:

1. public interface A {  2. public void doSomething(String thing);  3. }  1. public class AImpl implements A {  2. public void doSomething(String msg) { }  3. }  1. public class B {  2. public A doit() {  3. // more code here  4. }  5.  6. public String execute() { 7. // more code here  8. }  9. }  1. public class C extends B {  2. public AImpl doit() {  3. // more code here  4. }  5.  6. public Object execute() {  7. // more code here  8. }  9. }  Which statement is true about the classes and interfaces in the exhibit?() 

  • A、 Compilation will succeed for all classes and interfaces.
  • B、 Compilation of class C will fail because of an error in line 2.
  • C、 Compilation of class C will fail because of an error in line 6.
  • D、 Compilation of class AImpl will fail because of an error in line 2.

正确答案:C

第4题:

Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. public static void process(byte[]) { /* more code here */ }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?() 

  • A、 process(bytes);
  • B、 BitUtils.process(bytes);
  • C、 util.BitUtils.process(bytes);
  • D、 SomeApp cannot use methods in BitUtils.
  • E、 import util.BitUtils.*; process(bytes);

正确答案:C

第5题:

1. import java.util.*;  2. public class Example {  3. public static void main(String[] args) {  4. // insert code here  5. set.add(new integer(2));  6. set.add(new integer(l));  7. System.out.println(set);  8. }  9. }  Which code, inserted at line 4, guarantees that this program will output [1,2]? ()

  • A、 Set set = new TreeSet();
  • B、 Set set = new HashSet();
  • C、 Set set = new SortedSet();
  • D、 List set = new SortedList();
  • E、 Set set = new LinkedHashSet();

正确答案:A

第6题:

import java.util.*;  public class LetterASort {  public static void main(String[] args) {  ArrayList strings = new ArrayList();  strings.add(‟aAaA”);  strings.add(”AaA”); strings.add(‟aAa”);  strings.add(”AAaa”);  Collections.sort(strings);  for (String s: strings) { System.out.print(s + “ “); }  }  }  What is the result?() 

  • A、 Compilation fails.
  • B、 aAaA aAa AAaa AaA
  • C、 AAaa AaA aAa aAaA
  • D、 AaA AAaa aAaA aAa
  • E、 aAa AaA aAaA AAaa
  • F、 An exception is thrown at runtime.

正确答案:C

第7题:

Given a class Repetition: 1.package utils; 2. 3.public class Repetition{ 4.public static String twice(Strings){returns+s;} 5.} and given another class Demo: 1.//insert code here2. 3.public class Demo{ 4.public static void main(String[]args){ 5.System.out.println(twice("pizza")); 6.} 7.} Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()

  • A、import utils.*;
  • B、static import utils.*;
  • C、importutils.Repetition.*;
  • D、static importutils.Repetition.*;
  • E、import utils.Repetition.twice();
  • F、import static utils.Repetition.twice;
  • G、static import utils.Repetition.twice;

正确答案:F

第8题:

1. public class Test {   2. public static void main (String args) {   3. unsigned byte b = 0;   4. b--;   5.   6. }   7. }   What is the value of b at line 5?()  

  • A、 -1
  • B、 255
  • C、 127
  • D、 Compilation will fail.
  • E、 Compilation will succeed but the program will throw an exception at line 4.

正确答案:D

第9题:

Given classes defined in two different files:  1. package util;  2. public class BitUtils {  3. private static void process(byte[] b) { }  4. }  1. package app;  2. public class SomeApp {  3. public static void main(String[] args) {  4. byte[] bytes = new byte[256];  5. // insert code here  6. }  7. }  What is required at line 5 in class SomeApp to use the process method of BitUtils?() 

  • A、 process(bytes);
  • B、 BitUtils.process(bytes);
  • C、 app.BitUtils.process(bytes);
  • D、 util.BitUtils.process(bytes);
  • E、 import util.BitUtils. *; process(bytes);
  • F、 SomeApp cannot use the process method in BitUtils.

正确答案:F

第10题:

1. public class enclosingone (  2. public class insideone{}  3. )  4. public class inertest(  5. public static void main (string[]args)(  6. enclosingone eo= new enclosingone ();  7. //insert code here  8. )  9. )    Which statement at line 7 constructs an instance of the inner class?()  

  • A、 InsideOnew ei= eo.new InsideOn();
  • B、 Eo.InsideOne ei = eo.new InsideOne();
  • C、 InsideOne ei = EnclosingOne.new InsideOne();
  • D、 EnclosingOne.InsideOne ei = eo.new InsideOne();

正确答案:D

更多相关问题