单项选择题
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);
相关考题
-
单项选择题
34. HashMap props = new HashMap(); 35. props.put(”key45”, “some value”); 36. props.put(”key12”, “some other value”); 37. props.put(”key39”, “yet another value”); 38. Set s = props.keySet(); 39. // insert code here What, inserted at line 39, will sort the keys in the props HashMap?()
A. Arrays.sort(s);
B. s = new TreeSet(s);
C. Collections.sort(s);
D. s = new SortedSet(s); -
单项选择题
Given: ArrayList a = new ArrayList(); containing the values {“1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”} Which code will return 2?()
A. Collections. sort(a, a.reverse()); int result = Collections.binarySearch(a, “6”);
B. Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”);
C. Comparator c = Collections.reverseOrder(); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);
D. Comparator c = Collections.reverseOrder(a); Collections.sort(a, c); int result = Collections.binarySearch(a, “6”,c);
E. Comparator c = new InverseComparator(new Comparator()); Collections.sort(a); int result = Collections.binarySearch(a, “6”,c); -
单项选择题
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.
