1 / 24
文档名称:

think in java interview-高级开发人员面试宝典(二).pdf

格式:pdf   页数:24页
下载后只包含 1 个 PDF 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

think in java interview-高级开发人员面试宝典(二).pdf

上传人:翩仙妙玉 2013/12/22 文件大小:0 KB

下载得到文件列表

think in java interview-高级开发人员面试宝典(二).pdf

文档介绍

文档介绍:java_7star的专栏
think in java interview-高级开发人员面试宝典(二)
分类: 程序人生 2013-12-21 13:29 25人阅读评论(0) 收藏举报
面试
从现在开始,以样题的方式一一列出各种面试题以及点评,考虑到我在前文中说的,对于一些大型的外资型公司,
你将会面临全程英语面试,因此我在文章中也会出现许多全英语样题。
这些题目来自于各个真实的公司,公司名我就不一一例举了,是本人一直以来苦心收藏的。
一个JAVA 的MAIN方法引发的一场血案
Q:    What if the main method is declared as private?
A:     The piles properly but at run time it will give "Main method not public."
message.
Q: What if the static modifier is removed from the signature of the main method?
A:  piles. But at run time throws an error "NoSuchMethodError".
Q: What if I write static public void instead of public static void?
A:  piles and runs properly.
Q: What if I do not provide the String array as the argument to the method?
A:  piles but throws a run time error "NoSuchMethodError".
Q: What is the first argument of the String array in main method?
A:  The String array is empty. It does not have any element. This is unlike C/C++(读作plus plus)
where the first element by default is the program name.
Q: If I do not provide any arguments on mand line, then the String array of Main method will
be empty or null?
A:  It is empty. But not null.
Q: How can one prove that the array is notnull but empty using one line of code?
A:  Print . It will print 0. That means it is empty. But if it would have been null then
it would have thrown a NullPointerException on attempting to print .
仔细看完后有人直接吐血了,拿个eclipse,这几个问题全部模拟一边就可以了,即无算法也不需要死记硬背
1
有人会说了,唉,我怎么写了5年的JAVA怎么就没记得多写多看,多想想这个public static void main(String[]
args)方法呢?唉。。。
再来!!!
hashcode & equals之5重天
何时需要重写equals()
当一个类有自己特有的“逻辑相等”概念(不同于对象身份的概念)。
如何覆写equals()和hashcode
覆写equals方法
1  使用instanceof操作符检查“实参是否为正确的类型”。
2  对于类中的每一个“关键域”,检查实参中的域与当前对象中对应的域值。
3. 对于非float和double类型的原语类型域,使用==比较;
4  对于对象引用域,递归调用equals方法;
5  对于float域,使用Float. (afloat)转换为int,再使用==比较; floatToIntBits
6  对于double域,使用Double. (adouble)转换为int,再使用==比较; doubleToLongBits
7  对于数组域,。
覆写hashcode
1. 把某个非零常数值,例如1