一、在Java中,HashMap中是用哪些方法来解决哈希冲突的?
- 解决哈希冲突常用的两种方法是:开放定址法和链地址法
- 开放定址法:当冲突发生时,使用某种探查(亦称探测)技术在散列表中形成一个探查(测)序列。沿此序列逐个单元地查找,直到找到给定 的关键字,或者碰到一个开放的地址(即该地址单元为空)为止(若要插入,在探查到开放的地址,则可将待插入的新结点存人该地址单元)。查找时探查到开放的 地址则表明表中无待查的关键字,即查找失败。
- 链地址法:将所有关键字为同义词的结点链接在同一个单链表中。若选定的散列表长度为m,则可将散列表定义为一个由m个头指针组成的指针数 组T[0..m-1]。凡是散列地址为i的结点,均插入到以T[i]为头指针的单链表中。T中各分量的初值均应为空指针。
二、假设有以下代码String s = "hello";String t = "hello";char c [ ] = {'h','e','l','l','o'};下列选项中返回false的语句是?
s.equals (t);
t.equals (c);
s==t;
t.equals (new String ("hello"));
三、线程开启相关题目,如下图
以下程序的运行结果是?
四、下面哪些类实现或者继承了Collection接口?
五、下面的switch语句中,x可以是哪些类型的数据:()
switch(x)
{
default:
System.out.println("Hello");
} 六、在一个基于分布式的游戏服务器系统中,不同的服务器之间,哪种通信方式是不可行的()?
七、mysql数据库,game_order表表结构如下,下面哪些sql能使用到索引()?
select * from game_order where plat_game_id=5 and plat_id=134
select * from game_order where plat_id=134 and plat_game_id=5 and plat_order_id=’100’
select * from game_order where plat_order_id=’100’
select * from game_order where plat_game_id=5 and plat_order_id=’100’ and plat_id=134
select * from game_order where plat_game_id=5 and plat_order_id=’100’
八、下面哪些描述是正确的:( )
public class Test {
public static class A {
private B ref;
public void setB(B b) {
ref = b;
}
}
public static Class B {
private A ref;
public void setA(A a) {
ref = a;
}
}
public static void main(String args[]) {
…
start();
….
}
public static void start() { A a = new A();
B b = new B();
a.setB(b);
b = null; //
a = null;
…
}
}
b = null执行后b可以被垃圾回收
a = null执行后b可以被垃圾回收
a = null执行后a可以被垃圾回收
a,b必须在整个程序结束后才能被垃圾回收
类A和类B在设计上有循环引用,会导致内存泄露
a, b 必须在start方法执行完毕才能被垃圾回收




九、下面这条语句一共创建了多少个对象:String s="welcome"+"to"+360;
String test="javaandpython"; String str1="java"; String str2="and"; String str3="python"; System. out. println(test=="java"+"and"+"python"): System. out. println(test ==str1 + str2 + str3);
十、下列代码片段中,存在编译错误的语句是()
byte b1=1,b2=2,b3,b6,b8; final byte b4=4,b5=6,b7; b3=(b1+b2); /*语句1*/ b6=b4+b5; /*语句2*/ b8=(b1+b4); /*语句3*/ b7=(b2+b5); /*语句4*/ System.out.println(b3+b6);
十一、哪种调用是正确的
package cn.com.test;
public class EnclosingOne {
public class InsideOne {}
}
package cn.com.cow;
import cn.com.test.EnclosingOne;
import cn.com.test.EnclosingOne.InsideOne;
public class InerTest
{
public static void main(String[]args)
{
EnclosingOne eo = new EnclosingOne();
//insert code here
}
} InsideOne ei=eo.new InsideOne();
eo.InsideOne ei=eo.new InsideOne();
InsideOne ei=EnclosingOne.new InsideOne();
EnclosingOne.InsideOne ei=eo.new InsideOne();
十二、@SuppressWarnings(“deprecation”)的功能是什么?
十三、以下代码结果是什么?
public class foo {
public static void main(String sgf[]) {
StringBuffer a=new StringBuffer("A");
StringBuffer b=new StringBuffer("B");
operate(a,b);
System.out.println(a+"."+b);
}
static void operate(StringBuffer x,StringBuffer y) {
x.append(y);
y=x;
}
} 代码可以编译运行,输出“AB.AB”。
代码可以编译运行,输出“A.A”。
代码可以编译运行,输出“AB.B”。
代码可以编译运行,输出“A.B”。
十四、以下程序的输出结果为
class Base{
public Base(String s){
System.out.print("B");
}
}
public class Derived extends Base{
public Derived (String s) {
System.out.print("D");
}
public static void main(String[] args){
new Derived("C");
}
} BD
DB
C
编译错误
public Derived(String s){
super("s");
System.out.print("D");
} 十五、关于访问权限说法正确 的是 ? ( )
外部类前面可以修饰public,protected和private
成员内部类前面可以修饰public,protected和private
局部内部类前面可以修饰public,protected和private
以上说法都不正确
本文作者为DBC,转载请注明。


