A. java.util.Queue
B. java.util.ArrayList
C. java.util.LinearList
D. java.util.LinkedList
您可能感兴趣的试卷
你可能感兴趣的试题
public class Score implements Comparable
private int wins, losses;
public Score(int w, int 1) { wins = w; losses = 1; }
public int getWins() { return wins; }
public int getLosses() { return losses; }
public String toString() {
return “<“ + wins + “,“ + losses + “>”;
}
// insert code here
}
Which method will complete this class?()
A. public int compareTo(Object o) {/*mode 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*/}
1. import java.util.*;
2. public class TestSet {
3. enum Example { ONE, TWO, THREE }
4. public static void main(String[] args) {
5. Collection coll = new ArrayList();
6. coll.add(Example.THREE);
7. coll.add(Example.THREE);
8. coll.add(Example.THREE);
9. coll.add(Example.TWO);
10. coll.add(Example.TWO);
11. coll.add(Example.ONE);
12. Set set = new HashSet(coll);
13. }
14. }
Which statement is true about the set variable on line 12?()
A. The set variable contains all six elements from the coll collection, and the order is guaranteed to be preserved.
B. The set variable contains only three elements from the coll collection, and the order is guaranteed to be preserved.
C. The set variable contains all six elements from the coil collection, but the order is NOT guaranteed to be preserved.
D. The set variable contains only three elements from the coil collection, but the order is NOT guaranteed to be preserved.
import java.util.*;
public class WrappedString {
private String s;
public WrappedString(String s) { this.s = s; }
public static void main(String[] args) {
HashSet
A. 0
B. 1
C. 2
D. 3
E. 4
F. Compilation fails.
G. An exception is thrown at runtime.
import java.util.*;
public class PQ {
public static void main(String[] args) {
PriorityQueue
pq.add(”carrot”);
pq.add(”apple”);
pq.add(”banana”);
System.out.println(pq.poll() +”:” + pq.peek());
}
}
What is the result?()
A. apple:apple
B. carrot:apple
C. apple:banana
D. banana:apple
E. carrot:carrot
F. carrot:banana
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();
10. interface Jumper { public void jump(); }
......
20. class Animal {}
......
30. class Dog extends Animal { 31. Tail tail; 32. }
......
40. class Beagle extends Dog implements Jumper {
41. public void jump() { }
42. }
.......
50. class Cat implements Jumper {
51. public void jump() { }
52. }
Which three are true?()
A. Cat is-a Animal
B. Cat is-a Jumper
C. Dog is-a Animal
D. Dog is-a Jumper
E. Cat has-a Animal
F. Beagle has-a Tail
G. Beagle has-a Jumper
A. Inheritance represents an is-a relationship.
B. Inheritance represents a has-a relationship.
C. Interfaces must be used when creating a has-a relationship.
D. Instance variables can be used when creating a has-a relationship.
A. Has-a relationships should never be encapsulated.
B. Has-a relationships should be implemented using inheritance.
C. Has-a relationships can be implemented using instance variables.
D. Is-a relationships can be implemented using the extends keyword.
E. Is-a relationships can be implemented using the implements keyword.
F. An array or a collection can be used to implement a one-to-many has-a relationship.
G. The relationship between Movie and Actress is an example of an is-a relationship.
public class Team extends java.util.LinkedList {
public void addPlayer(Player p) {
add(p);
}
public void compete(Team opponent) { /* more code here */ }
}
class Player { /* more code here */ }
Which two are true?()
A. This code will compile.
B. This code demonstrates proper design of an is-a relationship.
C. This code demonstrates proper design of a has-a relationship.
D. A Java programmer using the Team class could remove Player objects from a Team object.
10. public class SuperCaic {
11. protected static int multiply(int a, int b) { return a * b; }
12. }
and:
20. public class SubCalc extends SuperCalc {
21. public static int multiply(int a, int b) {
22. int c = super.multiply(a, b);
23. return c;
24. }
25. }
and:
30. SubCalc sc = new SubCalc();
31. System.out.println(sc.multiply(3,4));
32. System.out.println(SubCalc.multiply(2,2));
What is the result?()
A. 12 4
B. The code runs with no output.
C. An exception is thrown at runtime.
D. Compilation fails because of an error in line 21.
E. Compilation fails because of an error in line 22.
F. Compilation fails because of an error in line 31.
最新试题
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()
What is the result?()
What can be a result?()
Which statement is true?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()
Which statement is true?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
Which statement is true?()
Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()