单选题import java.util.*;  class KeyMaster {  public int i;  public KeyMaster(int i) { this.i = i; }  public boolean equals(Object o) { return i == ((KeyMaster)o).i; }  public int hashCode() { return i; }  }  public class MapIt {  public static void main(String[] args) {  Set set = new HashSet();  KeyMaster k1 = new KeyMaster(1);  KeyMaster k2 = new KeyMaster(2);  set.add(k1); set.add(k1);  set.add(k2); set.add(k2);  System.out.print(set.size() + “:”);  k2.i = 1;  System.out.print(set.size() + “:”);  set.remove(k1);  System.out.print(set.size() + “:”);  set.remove(k2);  System.out.print(set.size()); }  }  What is the result?()A 4:4:2:2B 4:4:3:2C 2:2:1:0D 2:2:0:0E 2:1:0:0F 2:2:1:1G 4:3:2:1

单选题
import java.util.*;  class KeyMaster {  public int i;  public KeyMaster(int i) { this.i = i; }  public boolean equals(Object o) { return i == ((KeyMaster)o).i; }  public int hashCode() { return i; }  }  public class MapIt {  public static void main(String[] args) {  Set set = new HashSet();  KeyMaster k1 = new KeyMaster(1);  KeyMaster k2 = new KeyMaster(2);  set.add(k1); set.add(k1);  set.add(k2); set.add(k2);  System.out.print(set.size() + “:”);  k2.i = 1;  System.out.print(set.size() + “:”);  set.remove(k1);  System.out.print(set.size() + “:”);  set.remove(k2);  System.out.print(set.size()); }  }  What is the result?()
A

 4:4:2:2

B

 4:4:3:2

C

 2:2:1:0

D

 2:2:0:0

E

 2:1:0:0

F

 2:2:1:1

G

 4:3:2:1


参考解析

解析: 暂无解析

相关考题:

下面程序的目的是在屏幕上显示当前目录下的文件信息。文件信息通过表格JTable的实例显示。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。import java.awt.*;import javax.swing.*;import java.util. Date;import javax.swing.table.*;import java.applet.*;import java.io.*;public class Example3_10 extends JApplet, JFrame{public void init(){FileModel fm = new FileModel();JTable jt = new JTable();jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);jt.setColumnSelectionAllowed(true);JScrollPane jsp = new JScrollPane(jt);getContentPane().add(jsp, BorderLayout.CENTER);}public static void main(String args[]){Example3_10 ft = new Example3_10();ft.init();JFrame. f = new JFrame();f.setDefaultCloseOperation(JFrame.EXIT ON CLOSE);f.getContentPane() .add(ft.getContentPane());f.setSize (300, 400);f.show();}}class FileModel extends AbstractTableModel{String[] columnName = new String[] {"文件名", "大小", "最后修改时间"}Object[] [] data;public FileModel() { this("."); }public FileModel(String dir){File file = new File(dir);String files[] = file.list();data = new Object [files.length] [columnName.length];for (int i=0; i < files.length; i++){File tmp = new File (files[i]);data[i] [0] = tmp.getName();data[i] [1] = new Long(tmp.length());data[i] [2] = new Date(tmp.lastModified() );}}public int getColumnNumber(){return columnName.length;}public int getRowCount(){return data. length;}public String getColumnName(int col){return columnName[col];}public Object getValueAt(int row, int col){return data[row] [col];}public Class getColumnClass(int c){return getValueAt (0, c) .getClass();}}

能将程序补充完整的选项是( )。class Person{ private int a; public int change(int m){ return m; }}public class Teacher extends Person{ public int b; public static void main(String arg[]) { Person p = new Person(); Teacher t = new Teacher(); int i; ______ }} B.A.i=mB.i=bC. i=p.aD.i=p. change(50)

以下程序输出结果为______。 include using namespace std; class TestClass 1 { publi 以下程序输出结果为______。include<iostream>using namespace std;class TestClass 1{public:TestClass1(){}TestClass1(int i){x1=i;}void dispa(){cout<<"x1="<<x1<<",";}private:int x1;}:class TestClass2:public TestClass1{public:TestClass2(){}TestClass2(int i):TestClass1(i+10){x2=i:}void dispb(){dispa();cout<<"x2="<<x2<<end1;}private:int x2:}:int main(){TestClass2 b(2):b.dispb();return 0;}

若类A和类B的定义如下:includeclass A{int i,j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i,j; public: int geti() { return i; } }; class B:public A { int k; public: void make() { k=i*j; } }; 则上述定义中非法的表达式是( )。A.k=i*jB.int k;C.return i;D.void make();

能将程序补充完整的选项是______。 class Person{ private int a; phblic int change(int m){return m;} } public class Teacher extends Person{ public int b; public static void main(String arg[ ]){ Person p=new Person( ); Teacher t=new Teacher( ); int i; ______; } }A.i=mB.i=bC.i=p.aD.i=p.change(50)

有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a=i 有以下程序: #include<iostream> using namespace std; class A {private: int a; public: A(int i) {a=i;} void disp() {cout<<a<<“,”;}}; class B {private: int b; public: B(int j) {b=j;} void disp() {cout<<b<<“,”;A.10,10,10B.10,12,14C.8,10,12D.8,12,10

若类A和类B的定义如下class A{int i,j;public:int geti( ){return i;}};class B:public A{int k:public:void make( ){k=i*j;}};则上述定义中非法的语句是A.k=i*jB.int k;C.return i;D.void make()

在下面的类定义中,this指针的用途是______。 include class Sample { int x,y; publi 在下面的类定义中,this指针的用途是______。include<iostream.h>class Sample{int x,y;public:Sample(int i,int j){x=i;y=j;}void assign(Sample sa);};void Sample::assign(Sample p){if(this!=p){x=p.x;y=p.y;}}

下列类的定义中,有( ) 处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive: public Base { public: Derive(): Base(O) { } Derive(int x) { d=x; } void setvalue(int i) { data=i; } private: d; };A.1B.2C.3D.4

下列程序的输出结果是【 】。includeiostreamusing namespace std;class Base{public:int m,n;Base(int i,int j):m(i),n(j){}};class Derived:public Base{public:int m,k,;Derived(int i,int j):Base(i,j),m(i+1),k(j+1){}};int main(){Derived d(1,5);coutd.md.kd.n;return 0;}

将下面的程序补充完整。注意:不改动程序结构,不得增行或删行。import java.appplet.Applet;import java.awt.Graphics;public class ex1 extends Applet{public void paint(Graphics______){int i=682;gap.drawstring(Integer.______(i),20,60);}}

若类A和类B的定义如下: class A { int i,j; public: int geti () { return i; } }; class B : public A { int k; public: void make () { k=i*j; } }; 则上述定义中非法的语句是A.k=i*j;B.int k;C.return i;D.void make()

若类A和类B的定义如下:includeclass A{int i*j;public:int geti(){return i;}};class 若类A和类B的定义如下: #include<malloc.h> class A { int i*j; public: int geti() { return i; } }; class B: public A { int k; public: void make() { k=i*j; } ); 则上述定义中非法的表达式是( )。A.k=i*j;B.int k;C.return i;D.void make();

若有如下程序:includeusing namespace std;int s=O;class sample{static int n;publi 若有如下程序: #include<iostream> using namespace std; int s=O; class sample { static int n; public: sample(int i) { n=i; } static void add() { s+=n; } }; int sample::s=0; int main() { sample a(2),b(5); sample::add(); cout<<S<<end1; return 0; } 程序运行后的输出结果是A.2B.5C.7D.3

若类A和类B的定义如下: class A { int i,j; public: int geti() { return i; } }; class B: public A { int k; public: void make() { k=i*j } }; 则上述定义中A.k=i*j;B.int k;C.return i;D.void make()

选择正确的语句填在下列程序的横线处,使程序正常运行。 package ch1; import java. io. *; import j ava. util. *; class C45 implements Seritizable ______Public Thread t = new Thread(new T45(), "t"); public intcnt = 0; public C45() { t. start ( ) class T45 implements Runnable public int[] a = new int[4]; public void run() { for(int i - 0; i < 4; i++) { a[i] - i +4; } } } public class ex45 { static String fileName = "ch1\\file45.txt"; public static void main(String[] args) throws Exception { C45 bj = new C45 (); FileOutputStream fos = new FileOutputStream(fileName); ObjectOutputStream os = new ObjectOutputStream(fos); oos. writeObject (obj); oos.clese (); fos.close (); System. out, println (obj . toString ( ) ); } }A.transientB.protectedC.packageD.final

有以下程序:include using namespace std;int s=0;class sample{ static int n;publi 有以下程序: #include <iostream> using namespace std; int s=0; class sample { static int n; public: sample (int i) { n=i; } static void add() { s+=n; } }; int sample::n=0;A.2B.5C.7D.3

下列哪个选项的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 { }

设有如下程序:include class A{public:int i;display(){ cout 设有如下程序:#include <iostream. h>class A{public:int i;display(){ cout<<"class A\n"; }};class B{public:int i;display(){ cout<<"class B\n"; }};class C: public: A, public: B{int j;public:int i;show(){ j=i*i; display(); }};void main(){C demo;demo. show();}则主程序运行时,将( )。A.因为变量i的重复定义而报错B.因为对象demo间接调用display函数时产生歧义性而报错C.因为类定义的语法错误而不能运行D.没有语法错误,能够正常输出结果

有如下程序:includeusing namespace std;Class TestClass{int a;public:TestClass(in 有如下程序: #include<iostream> using namespace std; Class TestClass {int a; public: TestClass(int x){a=x;} void show(){cout<<a;}}; class TestClass1:public TestClass {int b; public: TestClass1(int i):TestClass(i+1),b(i){} voiA.5B.1C.0D.2

若有以下程序:includeusing namespace std;class A{private:int a;public:A(int i){a 若有以下程序: #include<iostream> using namespace std; class A {private: int a; public: A(int i) {a=i;} void disp() {cout<<a<<“,”;}}; class B {private: int b; public: B(int j {b=j;} void disp() {cout<<b<<A.10,10,10B.10,12,14C.8,10,12D.8,12,10

若有如下程序:includeusing namespace std;int s=0;class sample{static int n;publi 若有如下程序: #include<iostream> using namespace std; int s=0; class sample { static int n; public: sample(int i) { n=i; } static void add() { S+=n; } }; int sample::n=0; int main() { sample a(2),b(5); sample::add(); cout<<s<<endl; return 0; } 程序运行后的输出结果是( )。A.2B.5C.7D.3

下列类的定义中,有( )处语法错误。 class Base { public: Base(){} Base(int i) { data=i; } private: int data; }; class Derive : public Base { public: Derive() : Base(O) {} Derive (int x) { d=x; } void setvalue(int i) { data=i; } private: int d; };A.1B.2C.3D.4

下列程序的输出结果是______。 include class base { int x,y; public: base(int i,i 下列程序的输出结果是______。include<iostream.h>class base{int x,y;public:base(int i,int j){x=i;y=j;}virtual int add( ){return x+y;}};class three:public base{int z;public:three(int i,int j,int k):base(i,j){z=k;)int add( ){return(base::add( )+z);}};void main( ){three*q=new three(10,20,30);cout<<q->add( )<<endl;}

import java.util.*;  class Banana3 {  public static void main(String [] args) {  int x = 2;  Banana3 b = new Banana3();  b.go(x);  }  static { x += x; }  void go(int x) {  ++x;  System.out.println(x);  }  }  结果为:()  A、2B、3C、5D、编译失败

Which are syntactically valid statement at// point x?()     class Person {     private int a;  public int change(int m){  return m;  }     }  public class Teacher extends Person {     public int b;  public static void main(String arg[]){     Person p = new Person();     Teacher t = new Teacher();    int i;  // point x     }    } A、 i = m;B、 i = b;C、 i = p.a;D、 i = p.change(30);E、 i = t.b.

public class Parent {     int change() {…}     }  class Child extends Parent {     }  Which methods can be added into class Child?()    A、 public int change(){}B、 int chang(int i){}C、 private int change(){}D、 abstract int chang(){}