网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
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
参考答案
参考解析
解析:
暂无解析
更多 “单选题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” 相关考题
考题
能将程序补充完整的选项是( )。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)
考题
若类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)
考题
顺序执行下面的语句后,输出的结果是______。public class exl6{public static void main(String[] args){int i;int a[] = new int[10];for(i = O; i < a.length; i++)a[i] = i * 10 + j;for(i = 1; i < a.length; i++)if(a[i]%5 == O)System,out.println(a[i]);}}
考题
若类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()
考题
下列程序的功能是为变量赋值,程序运行后,输出i=51。请改动main方法中的错误,使程序能够正确编译、运行并输出正确的结果。注意:不改动程序结构。class A{private int a;public void setA (int x){a=x;}public int getA(){return a;}}public class MethodTest{public static void main(String args[]){A a=A();a.getA(51);int i=a.getA();System.out.println ("i="+i);}}
考题
若类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()
考题
有以下程序inclube class ClassOne{public: ClassOne(int v=O) { i=v;cout
有以下程序 #inclube <iostream.h> class ClassOne { public: ClassOne(int v=O) { i=v;cout<<i;} void print(){ cout<<i<<end1;} }; class ClassTwo { public: ClassTwo(int v=O) { i=v;cout<<i;} void print(){ cout<<i<<end1;} private: ClassOne myObj; int i; }; void main() { ClassTwo obj(1); obj.print(); }A.11B.111C.110D.101
考题
若类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();
考题
若类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.retum i;D.void make()
考题
若类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()
考题
public class Something {public static void main(String[] args) {Other o = new Other();new Something().addOne(o);}public void addOne(final Other o) {o.i++;}}class Other {public int i;}和上面的很相似,都是关于final 的问题,这有错吗?
考题
以下程序的运行结果为?class ValHold{public int i = 10;}public class ObParm{public static void main(String argv[]){ObParm o = new ObParm();o.amethod();}public void amethod(){int i = 99;ValHold v = new ValHold();v.i=30;another(v,i);System.out.print( v.i );}public void another(ValHold v, int i){i=0;v.i = 20;ValHold vh = new ValHold();v = vh;System.out.print(v.i);System.out.print(i);}}A.10030B. 20030C. 209930D. 10020
考题
下列程序的输出结果是______。 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;}
考题
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.
考题
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
考题
class Sock { String size; String color; public boolean equals(Object o) { Sock s = (Sock) o; return color.equals(s.color); } // insert code here } 哪两个满足 hashCode 的约定?()A、public int hashCode() { return 343; }B、public int hashCode() { return size.hashCode (); }C、public int hashCode() { return color.hashCode (); }D、public int hashCode() { return (int) (Math.random() * 1000);
考题
public class Test { public static void leftshift(int i, int j) { i=j; } public static void main(String args[]) { int i = 4, j = 2; leftshift(i, j); System.out.printIn(i); } } What is the result?() A、 2B、 4C、 8D、 16E、 The code will not compile.
考题
public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?() A、 i = 3B、 Compilation fails.C、 A ClassCastException is thrown at line 6.D、 A ClassCastException is thrown at line 7.
考题
public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?() A、 0B、 1C、 2D、 Compilation fails.
考题
public class test ( private static int j = 0; private static boolean methodB(int k) ( j += k; return true; ) public static void methodA(int i)( boolean b: b = i 10 | methodB (4); b = i 10 || methodB (8); ) public static void main (String args[])( methodA (0); system.out.printIn(j); ) ) What is the result?() A、 The program prints “0”B、 The program prints “4”C、 The program prints “8”D、 The program prints “12”E、 The code does not complete.
考题
public class SyncTest { private int x; private int y; public synchronized void setX (int i) (x=1;) public synchronized void setY (int i) (y=1;) public synchronized void setXY(int 1)(set X(i); setY(i);) public synchronized Boolean check() (return x !=y;) } Under which conditions will check () return true when called from a different class?A、 Check() can never return true.B、 Check() can return true when setXY is called by multiple threads.C、 Check() can return true when multiple threads call setX and setY separately.D、 Check() can only return true if SyncTest is changed to allow x and y to be set separately.
考题
单选题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
考题
单选题public class Test { public int aMethod() { static int i = 0; i++; return i; } public static void main (String args[]) { Test test = new Test(); test.aMethod(); int j = test.aMethod(); System.out.println(j); } } What is the result?()A
0B
1C
2D
Compilation fails.
考题
单选题public class Test { public static void main(String args[]) { class Foo { public int i = 3; } Object o = (Object)new Foo(); Foo foo = (Foo)o; System.out.println(“i = “ + foo.i); } } What is the result?()A
i = 3B
Compilation fails.C
A ClassCastException is thrown at line 6.D
A ClassCastException is thrown at line 7.
考题
单选题public class SyncTest { private int x; private int y; private synchronized void setX( int i ) { x = i; } private synchronized void setY( int i ) { y = i; } public void setXY( int i ) { setX(i); setY(i); } public synchronized boolean check() { return x != y; } } Under which condition will check return true when called from a different class? ()A
check can never return true.B
check can return true when setXY is called by multiple threads.C
check can return true when multiple threads call setX and setY separately.D
check can return true only if SyncTest is changed to allow x and y to be set separately.
考题
单选题public class SyncTest { private int x; private int y; public synchronized void setX (int i) (x=1;) public synchronized void setY (int i) (y=1;) public synchronized void setXY(int 1)(set X(i); setY(i);) public synchronized Boolean check() (return x !=y;) } Under which conditions will check () return true when called from a different class?A
Check() can never return true.B
Check() can return true when setXY is called by multiple threads.C
Check() can return true when multiple threads call setX and setY separately.D
Check() can only return true if SyncTest is changed to allow x and y to be set separately.
考题
单选题public class test ( private static int j = 0; private static boolean methodB(int k) ( j += k; return true; ) public static void methodA(int i)( boolean b: b = i 10 | methodB (4); b = i 10 || methodB (8); ) public static void main (String args[])( methodA (0); system.out.printIn(j); ) ) What is the result?()A
The program prints “0”B
The program prints “4”C
The program prints “8”D
The program prints “12”E
The code does not complete.
热门标签
最新试卷