1. 不允许访问 super.super.xxx 为什么?
super是当前类的私有成员,代表着父类,
super.super的意思是要访问父类中的私有成员,这个是不可能访问得到的
2.
1、15
2、0
3、6
4、6
> > > Object类中有clone方法,但是Object又没有实现cloneable接口,这是为什么?
Object类中的clone方法是protected的,它本省不是cloneable的,只是希望继承的class能够方便实现cloneable接口
> > > 对于一个没有实现cloneable的类来说,还是可以用从Object类继承而来的clone方法实现一些基本的值复制操作,那是不是可以说clone方法并没有对对象是否属于cloneable类型进行检验?
是的,实现了clone方法并不代表这个类就是cloneable类型的
protected的 clone方法,只能在类内调用,但是实现了cloneable接口的话,就可以不仅仅在类内来使用这个拷贝方法了
4.Which of the following statements about declaration are true?
A. Declaration of primitive types such as boolean, byte and so on does not allocate memory space for the variable.
B. Declaration of primitive types such as boolean, byte and so on allocates memory space for the variable.
C. Declaration of nonprimitive types such as String, Vector and so on does not allocate memory space for the object.
D. Declaration of nonprimitive types such as String, Vector ans so on allocates memory space for the object.
1,全局变量:
声明简单变量的时候系统会在stack(堆栈)中给它分配空间并给一个默认值的;
声明对象的时候,系统也会在stack(堆栈)中给他分配一个对象的指针,但只是指向null,而不是该对象的内存空间。
2,局部变量:
声明的时候都会在stack中分配空间(只不过对象的给分配的仍然是对象的指针),并且默认系统都不给初始化,因此只能先初始化才能使用。
由以上两点可以看出,BC是正确地。
5.一个文本文件中约有10万多行的数据,每个数据占一行(数据为一个整数)。要求:统计出总行数,并找出出现次数最多的那个整数。
大家帮忙,关键是怎样找出出现次数最多的那个数
packagetest;

importjava.io.*;
importjava.util.ArrayList;


publicclassTestArray...{


/**//*
*publicObject[]getList(){//获得数组!
*try{ArrayListlist=newArrayList();
*BufferedReaderin=
*newBufferedReader(newFileReader("d:\test"));
*Stringstr;
*if((str=in.readLine())!=null){
*list.add(str);
*}
*returnlist.toArray();
*
*}catch(Exceptione){
*e.printStackTrace();
*returnnull;}
*}
*/

publicObject[]getList()...{//测试数组
String[]bb=newString[200];

for(inti=0;i<bb.length;i++)...{
bb[i]=String.valueOf((int)(Math.random()*50));
}
returnbb;
}


publicintgetSize()...{//统计出总行数
Object[]o=getList();
returno.length;
}


publicint[]getMaxSameNo()...{//找出出现次数最多的那个数组

Objecto[]=getList();

intno[]=newint[o.length];

for(inti=0;i<o.length;i++)...{
no[i]=Integer.parseInt((String)o[i]);

}
java.util.Arrays.sort(no);//数组排序

for(inti=0;i<no.length;i++)...{
System.out.println("array["+i+"]="+no[i]);
}

intmaxsum=getSum(no);//出现次数最多的数到底出现了几次
returngetInt(no,maxsum);//找出出现次数最多的那个数

}


publicintgetSum(int[]no)...{//此方法返回出现次数最多的数到底出现了几次!
ArrayListsumlist=newArrayList();
intsum=1;

for(inti=0;i<no.length-1;i++)...{

if(no[i]==no[i+1])...{
sum++;//相临两个相等计数器+1

}else...{
//不相等向集合里加入
sumlist.add(sum);
//计数器复位继续比较
sum=1;
continue;
}
}
intmax=0;

for(inti=0;i<sumlist.size();i++)...{//此循环取出集合里最大的数!

if(Integer.parseInt(sumlist.get(i).toString())>max)...{
max=Integer.parseInt(sumlist.get(i).toString());
}
}
returnmax;
}


publicint[]getInt(int[]no,inta)...{//此方法返回出现次数为a的数组,可能有多个数字出现相同的次数的情况,所以返回的是数组
ArrayListsumlist=newArrayList();
intsum=1;

for(inti=0;i<no.length-1;i++)...{

if(no[i]==no[i+1])...{
sum++;

}else...{

if(sum==a)...{
sumlist.add(no[i]);
System.out.println(no[i]+"一共出现了"+a+"次!");
sum=1;
continue;

}else...{
sum=1;
continue;
}

}
}
intaa[]=newint[sumlist.size()];

for(inti=0;i<aa.length;i++)...{
aa[i]=Integer.parseInt((sumlist.get(i).toString()));
}
returnaa;

}


/***//**
*@paramargs
*/

publicstaticvoidmain(String[]args)...{
//TODO自动生成方法存根
TestArraytest=newTestArray();
intcount=test.getSize();
System.out.println("一共有"+count+"条记录!");
int[]max=test.getMaxSameNo();
System.out.println("出现次数最多的数为:");

for(inti=0;i<max.length;i++)...{
System.out.print(max[i]+",");
}

}

}