black

SCJP程序员认证考试

登录

单项选择题

import java.util.*; 
public class WrappedString { 
private String s; 
public WrappedString(String s) { this.s = s; } 
public static void main(String[] args) { 
HashSet hs = new HashSet(); 
WrappedString ws1 = new WrappedString(”aardvark”); 
WrappedString ws2 = new WrappedString(”aardvark”); 
String s1 = new String(”aardvark”); 
String s2 = new String(”aardvark”); 
hs.add(ws1); hs.add(ws2); hs.add(s1); hs.add(s2); 
System.out.println(hs.size()); } } 
What is the result?() 

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 = new PriorityQueue();  pq.add(”carrot”); pq.add(”apple”);  pq.add(”banana”);  System.out.println(pq.poll() +”:” + pq.peek()); }  }  What is the result?()

单项选择题 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]? ()

多项选择题 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?()

All Rights Reserved 版权所有©考试题库网(kstiku.com)

备案号:湘ICP备14005140号-3

经营许可证号:湘B2-20140064