单选题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”);  WrappedStri

题目
单选题
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.


相似考题
参考答案和解析
正确答案: F
解析: 暂无解析
更多“import java.util.*;  public class WrappedString {  private S”相关问题
  • 第1题:

    从对象流中读取对象,请在下面横线处填写代码完成此程序。

    import java.util. *;

    import java. io. *;

    public class UnSerializeDate

    {

    date d = null;

    UnSerializeDate ( )

    {

    try

    {

    FileInputStream f1 = new FileInputStream("date.ser");

    d = (Date) s. readobject ();

    f1,close();

    }

    catch (Exceptin e)

    {

    e. printStackTrace ();

    }

    }

    public static main(String args [] )

    {

    System.out.println("The date read is: "+ a.d.toString());

    }

    }


    正确答案:ObjeetInputStream s = new ObjectInputStream(f1 ); UnSerilizaDate a = new UnSerializeDate();
    ObjeetInputStream s = new ObjectInputStream(f1 ); UnSerilizaDate a = new UnSerializeDate();

  • 第2题:

    本题的功能是获取鼠标在窗口中的位置。当鼠标移进窗口中,就会实时显示鼠标在窗口中的相对位置,比如显示为"鼠标的当前位置:X:Y"(其中,X为横坐标,Y为纵坐标)。

    import java.awt.*;

    import java.awt.event.*;

    import java.util.*;

    import javax.swing.*;

    public class java2

    {

    public static void main(String[]args)

    {

    MouseFrame. frame=new MouseFrame();

    frame.setDefaultCloseoperation(JFrame.EXIT_

    0N CLOSE);

    frame.show();

    }

    }

    class MouseFrame. extends JFrame

    {

    public MouseFrame()

    {

    setTitle("java2");

    setSize(WIDTH,HEIGHT);

    MousePanel panel=new MousePanel();

    Container contentPane=getContentPane();

    contentPane.add(panel);

    }

    public static final int WIDTH = 300;

    public static final int HEIGHT=200;

    }

    class MousePanel extends JPanel

    {

    public MousePanel()

    {

    addMouseListener(new MouseHandler());

    addMouseMotionListener(new MouseMotionHan-

    dler());

    }

    public void paintComponent(Graphics g)

    super.paintComponent(g);

    String text="鼠标指针位置:"+mousex+":"

    +mousey;

    g.drawString(text,10,10);

    }

    private int mousex,mousey;

    private class MouseMotionHandler {

    public void mouseMoved(MouseEvent event)

    {

    mousex=event.getX();

    mousey=event.getY();

    repaint();

    }

    public void mouseDragged(MouseEvent event)

    {

    mousex=event.getX();

    mousey=event.getY();

    repaint();

    }

    }

    private class MouseHandler

    {

    public void mousePressed(MouseEvent eveat)

    {mousex=event.getX();

    mousey=event.getY();

    }

    }

    }


    正确答案:
    第1处:implementsMouseMotionListener第2处:extendsMouseAdapter【解析】第1处实现了MouseMotionListener接口鼠标移动事件的监听;第2处是继承MouseAdapter这个抽象类。

  • 第3题:

    Which three demonstrate an “is a” relationship?() 

    • A、 public class X {  }     public class Y extends X { }
    • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
    • C、 public interface Color { }     public class Shape { private Color color; }
    • D、 public interface Species { }     public class Animal { private Species species; }
    • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
    • F、 interface Component { }     class Container implements Component {   private Component[] children; }

    正确答案:A,B,F

  • 第4题:

    public class X {  public X aMethod() { return this;}  }  public class Y extends X {  }  Which two methods can be added to the definition of class Y?()

    • A、 public void aMethod() {}
    • B、 private void aMethod() {}
    • C、 public void aMethod(String s) {}
    • D、 private Y aMethod() { return null; }
    • E、 public X aMethod() { return new Y(); }

    正确答案:C,E

  • 第5题:

    Which the two demonstrate an “is a” relationship?()

    • A、 public interface Person {}  Public class Employee extends Person {}
    • B、 public interface Shape {}  public interface Rectangle extends Shape {}
    • C、 public interface Color {}  public class Shape { private Color color; }
    • D、 public class Species {}  public class Animal { private Species species; }
    • E、 interface Component {} Class Container implements Component {private Component [] children;

    正确答案:B,E

  • 第6题:

    Which two demonstrate an “is a” relationship?()   

    • A、 public interface Person { }  public class Employee extends Person { }
    • B、 public interface Shape { }  public class Employee extends Shape { }
    • C、 public interface Color { }  public class Employee extends Color { }
    • D、 public class Species { }  public class Animal (private Species species;)
    • E、 interface Component { }  Class Container implements Component ( Private Component[ ] children;  )

    正确答案:D,E

  • 第7题:

    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.

    正确答案:D

  • 第8题:

    单选题
    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.


    正确答案: D
    解析: 暂无解析

  • 第9题:

    单选题
    import java.util.*;  class ScanStuff {  public static void main(String [] args) {  String s = "x,yy,123";  Scanner sc = new Scanner(s);  while (sc.hasNext())  System.out.print(sc.next() + " ");  }  }  结果是什么?()
    A

    x yy

    B

    x,yy

    C

    x yy 123

    D

    x,yy,123


    正确答案: D
    解析: 暂无解析

  • 第10题:

    单选题
    与page指令 等价的是()。
    A

    <%@ import="“java.util.*" page=""><%@ import="“java.text.*" page=""><%@ import="“java.text.*" page=""><%@ import="“java.util.*" page=""><%@ import="“java.text.*" page=""><%@ import="“java.util.*" page=""><%@ page import= “java.util.* %> <%@ page import= “java.text.* “ %> 

    B

    <%@ page import= “java.util.*”  ,  import= “java.text.* “ %> 

    C

    <%@ page import= “java.util.* “  ;  %> <%@ page import= “java.text.* “  ; %>

    D

    <%@ page import= “java.util.* ; java.text.* “ %>


    正确答案: A
    解析: 暂无解析

  • 第11题:

    多选题
    Which the two demonstrate an “is a” relationship?()
    A

    public interface Person {}  Public class Employee extends Person {}

    B

    public interface Shape {}  public interface Rectangle extends Shape {}

    C

    public interface Color {}  public class Shape { private Color color; }

    D

    public class Species {}  public class Animal { private Species species; }

    E

    interface Component {} Class Container implements Component {private Component [] children;


    正确答案: B,A
    解析: 暂无解析

  • 第12题:

    单选题
    现有:  import java.util.*;      class AddStuff2  {  public static void main(String  []  args)  {      TreeSett=new TreeSet();      if (t.add("one"))      if (t.add("two"))     if (t.add ("three"))  add("four");  for (String s  :  t)      System.out.print (s);     }      }      结果为:()
    A

     one

    B

     one three two

    C

     one two three

    D

     one two three four

    E

     four one three two

    F

    编译失败


    正确答案: D
    解析: 暂无解析

  • 第13题:

    下列哪个选项的java源文件程序段是不正确的? ( )

    A.package testpackage; public class Test{ }

    B.import java.io.*; package testpackage; public class Test{ }

    C.import java.i.*; class Person{} public class Test{ }

    D.import java.io.*; import java.awt.*; public class Test { }


    正确答案:B

  • 第14题:

    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

  • 第15题:

    与page指令<%@ page import= “java.util.*, java.text.* “ %> 等价的是()。

    • A、<%@ import="“java.util.*" page=""><%@ import="“java.text.*" page=""><%@ import="“java.text.*" page=""><%@ import="“java.util.*" page=""><%@ import="“java.text.*" page=""><%@ import="“java.util.*" page=""><%@ page import= “java.util.* %> <%@ page import= “java.text.* “ %> 
    • B、<%@ page import= “java.util.*”  ,  import= “java.text.* “ %> 
    • C、<%@ page import= “java.util.* “  ;  %> <%@ page import= “java.text.* “  ; %>
    • D、<%@ page import= “java.util.* ; java.text.* “ %>

    正确答案:A

  • 第16题:

    现有:  import java.util.*;      class AddStuff2  {  public static void main(String  []  args)  {      TreeSett=new TreeSet();      if (t.add("one"))      if (t.add("two"))     if (t.add ("three"))  add("four");  for (String s  :  t)      System.out.print (s);     }      }      结果为:()     

    • A、 one
    • B、 one three two
    • C、 one two three
    • D、 one two three four
    • E、 four one three two
    • F、编译失败

    正确答案:E

  • 第17题:

    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

  • 第18题:

    定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()     

    • A、import utils.*;
    • B、 import utils.Rep.*;
    • C、 import static utils.Rep.twice;
    • D、 static import utils.Rep.twice;

    正确答案:C

  • 第19题:

    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()

    • A、 public class Circle implements Shape { private int radius; }
    • B、 public abstract class Circle extends Shape { private int radius; }
    • C、 public class Circle extends Shape { private int radius; public void draw(); }
    • D、 public abstract class Circle implements Shape { private int radius; public void draw(); }
    • E、 public class Circle extends Shape { private int radius;public void draw() {/* code here */} }
    • F、 public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }

    正确答案:B,E

  • 第20题:

    多选题
    Which three demonstrate an “is a” relationship?()
    A

    public class X {  }     public class Y extends X { }

    B

    public interface Shape { }     public interface Rectangle extends Shape{ }

    C

    public interface Color { }     public class Shape { private Color color; }

    D

    public interface Species { }     public class Animal { private Species species; }

    E

    public class Person { }    public class Employee {      public Employee(Person person) { }

    F

    interface Component { }     class Container implements Component {   private Component[] children; }


    正确答案: A,F
    解析: 暂无解析

  • 第21题:

    多选题
    public abstract class Shape {  private int x;  private int y;  public abstract void draw();  public void setAnchor(int x, int y) {  this.x = x;  this.y = y;  }  }  Which two classes use the Shape class correctly?()
    A

    public class Circle implements Shape { private int radius; }

    B

    public abstract class Circle extends Shape { private int radius; }

    C

    public class Circle extends Shape { private int radius; public void draw(); }

    D

    public abstract class Circle implements Shape { private int radius; public void draw(); }

    E

    public class Circle extends Shape { private int radius;public void draw() {/* code here */} }

    F

    public abstract class Circle implements Shape { private int radius;public void draw() { / code here */ } }


    正确答案: B,E
    解析: 暂无解析

  • 第22题:

    单选题
    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.


    正确答案: B
    解析: 暂无解析

  • 第23题:

    单选题
    定义类:      package utils;      public class Rep{  public static String twice (String s){return s+s ;}     }  再定义另一个类Demo:      //insert code here      public class Demo{  public static void main (String[]  args){      System. out .println( twice( "Hello"));      }      }  在第一行插入哪项代码,可以使程序正常编译和执行?()
    A

    import utils.*;

    B

     import utils.Rep.*;

    C

     import static utils.Rep.twice;

    D

     static import utils.Rep.twice;


    正确答案: C
    解析: 暂无解析

  • 第24题:

    单选题
    Given a class Repetition:  1. package utils;  2.  3. public class Repetition {  4. public static String twice(String s) { return s + s; }  5. }  and given another class Demo:  1. // insert code here 2.  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

     import utils.Repetition.*;

    D

     static import utils.Repetition. *;

    E

     import utils.Repetition.twice();

    F

     import static utils.Repetition.twice;

    G

     static import utils.Repetition.twice;


    正确答案: B
    解析: 暂无解析