答:用插入法进行排序代码如下packagetest;.*;class InsertSort{ArrayListal;publicInsertSort(intnum,intmod){al=newArrayList(num);Randomrand=newRandom();("TheArrayListSortBefore:");for(inti=0;i){(newInteger((())%mod+1));("al["+i+"]="+(i));}}publicvoidSortIt(){ntegertempInt;intMaxSize=1;for(inti=1;i ){tempInt=(Integer)(i);if(()>=((Integer)(MaxSize-1)).intValue()){(MaxSize,tempInt);MaxSize++;(());}else{for(intj=0;j){if(((Integer)(j)).intValue()>=()){(j,tempInt);MaxSize++;(());break;}}}}("TheArrayListSortAfter:");for(inti=0;i){("al["+i+"]="+(i));}}publicstaticvoidmain(String[]args){InsertSortis=newInsertSort(10,100);();}}4、抽象类与接口?答:抽象类与接口都用于抽象,但是抽象类(JAVA中)可以有自己的部分实现,而接口则完全是一个标识(同时有多重继承的功能)。5、float型floatf=?答:不正确。精度不准确,应该用强制类型转换,如下所示:floatf=(float)、介绍JAVA中的CollectionFrameWork(包括如何写自己的数据结构)?答:CollectionFrameWork如下:Collection├List│├LinkedList│├ArrayList│└Vector│└Stack└SetMap├Hashtable├HashMap└WeakHashMapCollection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements)Map提供key到value的映射7、内部类的实现方式?答:示例代码如下:packagetest;lass OuterClass{privateclassInterClass{publicInterClass(){("InterClassCreate");}}publicOuterClass(){InterCl
Java基础面试 来自淘豆网m.daumloan.com转载请标明出处.