Java面试题及部分解答

1。请大概描述一下Vector和ArrayList的区别,Hashtable和HashMap的区别。(5) 

2。请问你在什么情况下会在你的JAVA代码中使用可序列化?(5) 
为什么放到HttpSession中的对象必须要是可序列化的?(5) 

3。为什么在重写了equals()方法之后也必须重写hashCode()方法?(10) 

4。sleep()和wait()有什么区别?(10) 

5。编程题:用最有效率的方法算出2乘以17等于多少?(5) 

6。JAVA是不是没有内存泄漏问题?看下面的代码片段,并指出这些代码隐藏的问题。(10) 
Object[] elements = new Object[10]; 
int size; 
...

public Object pop() { 
if (size == 0) 
return null; 
Object o = elements[--size]; 
return o; 


7。请阐述一下你对JAVA多线程中锁的概念的理解。(10) 

8。所有的递归实现都可以用循环的方式实现,请描述一下这两种实现方式各自的优劣。 
并举例说明在什么情况下可以使用递归,而在什么情况下只能使用循环而不能使用递归?(5) 

9。请简要讲一下你对测试驱动开发(TDD)的认识。(10) 

10。请阐述一下你对面向接口编程的理解。(10) 

11。在J2EE中有一个容器(Container)的概念,不管是EJB、PICO还是Spring都有他们 
各自实现的容器,受容器管理的组件会具有有生命周期的特性,请问,为什么需要容器? 
它的好处在哪里?它会带来什么样的问题?(15) 

12。请阐述一下你对IOC(Inversion of Control)的理解。(可以以PICO和Spring的IOC作为例子说明他们在实现上各自的特点)(10) 

13。下面的代码在绝大部分时间内都运行得很正常,请问在什么情况下会出现问题?问题的根源在哪里?(10) 
import java.util.LinkedList; 

public class Stack { 

LinkedList list = new LinkedList(); 

public synchronized void push(Object x) { 
synchronized(list) { 
list.addLast( x ); 
notify(); 



public synchronized Object pop() 
throws Exception { 
synchronized(list) { 
if( list.size() = 0 ) { 
wait(); 

return list.removeLast(); 





解答:
。请大概描述一下Vector和ArrayList的区别,Hashtable和HashMap的区别。(5)线程安全与否

2。请问你在什么情况下会在你的JAVA代码中使用可序列化?(5)cluster中session复制,缓存persist与reload
为什么放到HttpSession中的对象必须要是可序列化的?(5)没必须,不过session反序列化过程会导致对象不可用.

3。为什么在重写了equals()方法之后也必须重写hashCode()方法?(10)API规范

4。sleep()和wait()有什么区别?(10)前者占用CPU,后者空闲CPU

5。编程题:用最有效率的方法算出2乘以17等于多少?(5)171

6。JAVA是不是没有内存泄漏问题?看下面的代码片段,并指出这些代码隐藏的问题。(10)不是
...
...没发现内存泄漏的问题

7。请阐述一下你对JAVA多线程中锁的概念的理解。(10)同步因子,在某段代码上增加同步因子,那么整个JVM内部只能最多有一个线程执行这段,其余的线程按FIFO方式等待执行.

8。所有的递归实现都可以用循环的方式实现,请描述一下这两种实现方式各自的优劣。
并举例说明在什么情况下可以使用递归,而在什么情况下只能使用循环而不能使用递归?(5)没发现所有的递归都可以用循环实现的,尤其是那种不知道循环重数的递归算法.递归的优点是简炼,抽象性好;循环则更直观.递归一般用于处理一级事务能转化成更简的二级事务的操作.归纳不出二级事务或者二级事务更复杂的情况不能用.

9。请简要讲一下你对测试驱动开发(TDD)的认识。(10)不认识

10。请阐述一下你对面向接口编程的理解。(10)1,利于扩展;2,暴露更少的方法;

11。在J2EE中有一个容器(Container)的概念,不管是EJB、PICO还是Spring都有他们
各自实现的容器,受容器管理的组件会具有有生命周期的特性,请问,为什么需要容器?
它的好处在哪里?它会带来什么样的问题?(15)组件化,框架设计...

12。请阐述一下你对IOC(Inversion of Control)的理解。(可以以PICO和Spring的IOC作为例子说明他们在实现上各自的特点)(10)不理解

13。下面的代码在绝大部分时间内都运行得很正常,请问在什么情况下会出现问题?问题的根源在哪里?(10)wait和notify使用目的不能达到,wait()的obj,自身不能notify().出题人对wait和notify机制不够理解.
import java.util.LinkedList;

public class Stack {

LinkedList list = new LinkedList();

public synchronized void push(Object x) {
synchronized(list) { 
list.addLast( x );
notify();
}
}

public synchronized Object pop()
throws Exception { 
synchronized(list) { 
if( list.size() = 0 ) {
wait();
}
return list.removeLast();
}
}
}

你拿了多少分?


http://v.17173.com/playlist_15876575?retcode=0
http://v.17173.com/playlist_15876620?retcode=0
http://v.17173.com/playlist_15876669?retcode=0
http://v.17173.com/playlist_15876721?retcode=0
http://v.17173.com/playlist_15876994?retcode=0
http://v.17173.com/playlist_15877073?retcode=0
http://v.17173.com/playlist_15877114?retcode=0
http://v.17173.com/playlist_15877193?retcode=0
http://v.17173.com/playlist_15877226?retcode=0
http://v.17173.com/playlist_15877272?retcode=0
http://v.17173.com/playlist_15877314?retcode=0
http://v.17173.com/playlist_15877348?retcode=0
http://v.17173.com/playlist_15877380?retcode=0
http://v.17173.com/playlist_15877412?retcode=0
http://v.17173.com/playlist_15877440?retcode=0
http://v.17173.com/playlist_15877475?retcode=0
http://v.17173.com/playlist_15877527?retcode=0
http://v.17173.com/playlist_15877553?retcode=0
http://v.17173.com/playlist_15877584?retcode=0
http://v.17173.com/playlist_15877609?retcode=0
http://v.17173.com/playlist_15877698?retcode=0
http://v.17173.com/playlist_15877728?retcode=0
http://v.17173.com/playlist_15877773?retcode=0
http://v.17173.com/playlist_15877831?retcode=0
http://v.17173.com/playlist_15877877?retcode=0
http://v.17173.com/playlist_15877910?retcode=0
http://v.17173.com/playlist_15877964?retcode=0
http://v.17173.com/playlist_15878006?retcode=0
http://v.17173.com/playlist_15878063?retcode=0
http://v.17173.com/playlist_15878122?retcode=0
http://v.17173.com/playlist_15878153?retcode=0
http://v.17173.com/playlist_15878188?retcode=0
http://v.17173.com/playlist_15878235?retcode=0
http://v.17173.com/playlist_15878324?retcode=0
http://v.17173.com/playlist_15878375?retcode=0
http://v.17173.com/playlist_15878455?retcode=0
http://v.17173.com/playlist_15878502?retcode=0
http://v.17173.com/playlist_15878531?retcode=0
http://v.17173.com/playlist_15878607?retcode=0
http://v.17173.com/playlist_15878639?retcode=0
http://v.17173.com/playlist_15878668?retcode=0
http://v.17173.com/playlist_15878759?retcode=0
http://v.17173.com/playlist_15878796?retcode=0
http://v.17173.com/playlist_15878858?retcode=0
http://v.17173.com/playlist_15878897?retcode=0
http://v.17173.com/playlist_15878934?retcode=0
http://v.17173.com/playlist_15878970?retcode=0
http://v.17173.com/playlist_15879033?retcode=0
http://v.17173.com/playlist_15879121?retcode=0
http://v.17173.com/playlist_15879155?retcode=0
http://v.17173.com/playlist_15879194?retcode=0
http://v.17173.com/playlist_15879264?retcode=0
http://v.17173.com/playlist_15879297?retcode=0
http://v.17173.com/playlist_15879422?retcode=0
http://v.17173.com/playlist_15879468?retcode=0
http://v.17173.com/playlist_15879502?retcode=0
http://v.17173.com/playlist_15879588?retcode=0
http://v.17173.com/playlist_15879698?retcode=0
http://v.17173.com/playlist_15879787?retcode=0
http://v.17173.com/playlist_15879847?retcode=0
http://v.17173.com/playlist_15882791?retcode=0
http://v.17173.com/playlist_15882832?retcode=0
http://v.17173.com/playlist_15882897?retcode=0
http://v.17173.com/playlist_15883034?retcode=0
http://v.17173.com/playlist_15883172?retcode=0
http://v.17173.com/playlist_15883343?retcode=0
http://v.17173.com/playlist_15883739?retcode=0
http://v.17173.com/playlist_15883806?retcode=0
http://v.17173.com/playlist_15883863?retcode=0
http://v.17173.com/playlist_15883907?retcode=0
http://v.17173.com/playlist_15883997?retcode=0
http://v.17173.com/playlist_15884047?retcode=0
http://v.17173.com/playlist_15884097?retcode=0
http://v.17173.com/playlist_15884187?retcode=0
http://v.17173.com/playlist_15884238?retcode=0
http://v.17173.com/playlist_15884294?retcode=0
http://v.17173.com/playlist_15884352?retcode=0
http://v.17173.com/playlist_15884402?retcode=0
http://v.17173.com/playlist_15884458?retcode=0
http://v.17173.com/playlist_15884512?retcode=0
http://v.17173.com/playlist_15884614?retcode=0
http://v.17173.com/playlist_15885018?retcode=0
http://v.17173.com/playlist_15885086?retcode=0
http://v.17173.com/playlist_15885126?retcode=0
http://v.17173.com/playlist_15885165?retcode=0
http://v.17173.com/playlist_15885214?retcode=0
http://v.17173.com/playlist_15885277?retcode=0
http://v.17173.com/playlist_15885365?retcode=0
http://v.17173.com/playlist_15885465?retcode=0
http://v.17173.com/playlist_15885609?retcode=0
http://v.17173.com/playlist_15885681?retcode=0
http://v.17173.com/playlist_15885783?retcode=0
http://v.17173.com/playlist_15886145?retcode=0
http://v.17173.com/playlist_15886197?retcode=0
http://v.17173.com/playlist_15886246?retcode=0
http://v.17173.com/playlist_15886331?retcode=0
http://v.17173.com/playlist_15886491?retcode=0
http://v.17173.com/playlist_15886565?retcode=0
http://v.17173.com/playlist_15886599?retcode=0
http://v.17173.com/playlist_15886674?retcode=0
http://v.17173.com/playlist_15886746?retcode=0
http://v.17173.com/playlist_15887391?retcode=0
http://v.17173.com/playlist_15887533?retcode=0
http://v.17173.com/playlist_15887607?retcode=0
http://v.17173.com/playlist_15888028?retcode=0
http://v.17173.com/playlist_15888073?retcode=0
http://v.17173.com/playlist_15888120?retcode=0
http://v.17173.com/playlist_15888209?retcode=0
http://v.17173.com/playlist_15888287?retcode=0
http://v.17173.com/playlist_15888342?retcode=0
http://v.17173.com/playlist_15888468?retcode=0
http://v.17173.com/playlist_15888506?retcode=0
http://v.17173.com/playlist_15888555?retcode=0
http://v.17173.com/playlist_15888703?retcode=0
http://v.17173.com/playlist_15888747?retcode=0
http://v.17173.com/playlist_15888859?retcode=0
http://www.huihui.cn/share/32814324
http://www.huihui.cn/share/32814392
http://www.huihui.cn/share/32814494
http://www.huihui.cn/share/32814532
http://www.huihui.cn/share/32814748
http://www.huihui.cn/share/32814894
http://www.huihui.cn/share/32815046
http://www.huihui.cn/share/32815140
http://www.huihui.cn/share/32815182
http://www.huihui.cn/share/32815298
http://www.huihui.cn/share/32815384
http://www.huihui.cn/share/32815496
http://www.huihui.cn/share/32815562
http://www.huihui.cn/share/32815612
http://www.huihui.cn/share/32815778
http://www.huihui.cn/share/32815828
http://www.huihui.cn/share/32815922
http://www.huihui.cn/share/32816116
http://www.huihui.cn/share/32816304
http://www.huihui.cn/share/32816424
http://www.huihui.cn/share/32816540
http://www.huihui.cn/share/32816688
http://www.huihui.cn/share/32816896
http://www.huihui.cn/share/32817028
http://www.huihui.cn/share/32817086
http://www.huihui.cn/share/32817152
http://www.huihui.cn/share/32817226
http://www.huihui.cn/share/32817290
http://www.huihui.cn/share/32817350
http://www.huihui.cn/share/32817418
http://www.huihui.cn/share/32817582
http://www.huihui.cn/share/32817710
http://www.huihui.cn/share/32817826
http://www.huihui.cn/share/32817898
http://www.huihui.cn/share/32817960
http://www.huihui.cn/share/32818050
http://www.huihui.cn/share/32818156
http://www.huihui.cn/share/32818212
http://www.huihui.cn/share/32818294
http://www.huihui.cn/share/32818418
http://www.huihui.cn/share/32818528
http://www.huihui.cn/share/32818648
http://www.huihui.cn/share/32818714
http://www.huihui.cn/share/32818948
http://www.huihui.cn/share/32819078
http://www.huihui.cn/share/32819168
http://www.huihui.cn/share/32819268
http://www.huihui.cn/share/32819502
http://www.huihui.cn/share/32819604
http://www.huihui.cn/share/32819646
http://www.huihui.cn/share/32819696
http://www.huihui.cn/share/32819758
http://www.huihui.cn/share/32819818
http://www.huihui.cn/share/32819996
http://www.huihui.cn/share/32820142
http://www.huihui.cn/share/32820206
http://www.huihui.cn/share/32820264
http://www.huihui.cn/share/32820356
http://www.huihui.cn/share/32820414
http://www.huihui.cn/share/32820500
http://www.huihui.cn/share/32820596
http://www.huihui.cn/share/32820654
http://www.huihui.cn/share/32820772
http://www.huihui.cn/share/32820842
http://www.huihui.cn/share/32820962
http://www.huihui.cn/share/32821010
http://www.huihui.cn/share/32821062
http://www.huihui.cn/share/32821148
http://www.huihui.cn/share/32821204
http://www.huihui.cn/share/32821250
http://www.huihui.cn/share/32821332
http://www.huihui.cn/share/32821444
http://www.huihui.cn/share/32821624
http://www.huihui.cn/share/32821740
http://www.huihui.cn/share/32821832
http://www.huihui.cn/share/32821914
http://www.huihui.cn/share/32821996
http://www.huihui.cn/share/32822090
http://www.huihui.cn/share/32822278
http://www.huihui.cn/share/32822722
http://www.huihui.cn/share/32823112
http://www.huihui.cn/share/32823194
http://www.huihui.cn/share/32823282
http://www.huihui.cn/share/32823380
http://www.huihui.cn/share/32823470
http://www.huihui.cn/share/32823668
http://www.huihui.cn/share/32823730
http://www.huihui.cn/share/32823930
http://www.huihui.cn/share/32823980
http://www.huihui.cn/share/32824054
http://www.huihui.cn/share/32824150
http://www.huihui.cn/share/32824228
http://www.huihui.cn/share/32824350
http://www.huihui.cn/share/32824416
http://www.huihui.cn/share/32824496
http://www.huihui.cn/share/32824576
http://www.huihui.cn/share/32824638
http://www.huihui.cn/share/32824682
http://www.huihui.cn/share/32824744
http://www.huihui.cn/share/32824816
http://www.huihui.cn/share/32825416
http://www.huihui.cn/share/32825480
http://www.huihui.cn/share/32825558
http://www.huihui.cn/share/32825682
http://www.huihui.cn/share/32825798
http://www.huihui.cn/share/32825904
http://www.huihui.cn/share/32825962
http://www.huihui.cn/share/32826048
http://www.huihui.cn/share/32826118
http://www.huihui.cn/share/32826252
http://www.huihui.cn/share/32826374
http://www.huihui.cn/share/32826456
http://www.huihui.cn/share/32826524
http://www.huihui.cn/share/32826584
http://www.huihui.cn/share/32826700
http://www.huihui.cn/share/32826814
http://ycool.com/post/g9zd7gp
http://ycool.com/post/ynd3xkn
http://ycool.com/post/ddy7uy4
http://ycool.com/post/rc9tmq7
http://ycool.com/post/rsq4ree
http://ycool.com/post/z74jnt7
http://ycool.com/post/hxcpt5j
http://ycool.com/post/m3a2yzn
http://ycool.com/post/xuuhbc6
http://ycool.com/post/ef643xj
http://ycool.com/post/sc3ux6j
http://ycool.com/post/r9h3fkv
http://ycool.com/post/45rf5yg
http://ycool.com/post/xb796ru
http://ycool.com/post/4xgyx3v
http://ycool.com/post/9dz8e87
http://ycool.com/post/4v52ztj
http://ycool.com/post/jjgqkjj
http://ycool.com/post/bzf88ar
http://ycool.com/post/ffg9zxt
http://ycool.com/post/munbyv9
http://ycool.com/post/evd466r
http://ycool.com/post/b292aeq
http://ycool.com/post/yeb4y7c
http://ycool.com/post/4zkv7xj
http://ycool.com/post/yardshm
http://ycool.com/post/vmq98cc
http://ycool.com/post/fu55rn6
http://ycool.com/post/wj3bepc
http://ycool.com/post/3mkfujd
http://ycool.com/post/bxveebm
http://ycool.com/post/tau89q6
http://ycool.com/post/uq8du6u
http://ycool.com/post/k3a7zxf
http://ycool.com/post/3wpk9x8
http://ycool.com/post/s2h8746
http://ycool.com/post/xw8kc8r
http://ycool.com/post/58snqss
http://ycool.com/post/7rceu4g
http://ycool.com/post/vhw3szv
http://ycool.com/post/82vbhxk
http://ycool.com/post/m5sjfnd
http://ycool.com/post/vkvkxug
http://ycool.com/post/626wy7v
http://ycool.com/post/jba4qyw
http://ycool.com/post/mpknrnx
http://ycool.com/post/mm42uwz
http://ycool.com/post/6quhbjp
http://ycool.com/post/hsugu43
http://ycool.com/post/q57s7v8
http://ycool.com/post/7rcrjmd
http://ycool.com/post/dpn5hfd
http://ycool.com/post/j92j9n8
http://ycool.com/post/a6eus7m
http://ycool.com/post/dtqmjh8
http://ycool.com/post/a6qxrkm
http://ycool.com/post/xsk457k
http://ycool.com/post/b95zjgh
http://ycool.com/post/megdqxf
http://ycool.com/post/d3khjf5
http://ycool.com/post/qjtmzry
http://ycool.com/post/aqb6jyq
http://ycool.com/post/cp98tv4
http://ycool.com/post/mqt32wp
http://ycool.com/post/szk4snd
http://ycool.com/post/rqsrytm
http://ycool.com/post/u96q2mf
http://ycool.com/post/svhrgh5
http://ycool.com/post/ze8akv6
http://ycool.com/post/wb5sse4
http://ycool.com/post/yjzu2k3
http://ycool.com/post/vu6xkjd
http://ycool.com/post/azgh44q
http://ycool.com/post/e9z9x5b
http://ycool.com/post/tb5fruf
http://ycool.com/post/fc2q8jm
http://ycool.com/post/7as4erz
http://ycool.com/post/5zmvt4m
http://ycool.com/post/etp3w8d
http://ycool.com/post/k2bt278
http://ycool.com/post/fgqcrvr
http://t.163.com/event/info/eventId/8564006048693590530
http://t.163.com/event/info/eventId/8858107697125982736
http://t.163.com/event/info/eventId/1842432775415591006
http://www.zhihu.com/collection/33341516
http://www.zhihu.com/collection/33341704
http://www.zhihu.com/collection/33341938
http://www.zhihu.com/collection/33342123
http://www.zhihu.com/collection/33342337
http://www.zhihu.com/collection/33342570
http://www.zhihu.com/collection/33342805
http://www.zhihu.com/collection/33343053
http://www.zhihu.com/collection/33343347
http://www.zhihu.com/collection/33343594
http://www.zhihu.com/collection/33343795
http://www.zhihu.com/collection/33344028
http://www.zhihu.com/collection/33344328
http://www.zhihu.com/collection/33345863
http://www.zhihu.com/collection/33347149
http://www.zhihu.com/collection/33347403
http://www.zhihu.com/collection/33347652
http://www.zhihu.com/collection/33347937
http://www.zhihu.com/collection/33348162
http://www.zhihu.com/collection/33348424
http://www.zhihu.com/collection/33348702
http://www.zhihu.com/collection/33348978
http://home.eduu.com/4508113/blog/3592995
http://home.eduu.com/4508113/blog/3594368
http://home.eduu.com/4508113/blog/3597013
http://home.eduu.com/4508113/blog/3597524
http://home.eduu.com/4508113/blog/3598319
http://home.eduu.com/4508113/blog/3598876
http://www.zhihu.com/collection/33422361
http://www.zhihu.com/collection/33422801
http://www.zhihu.com/collection/33423013
http://www.zhihu.com/collection/33423228
http://www.zhihu.com/collection/33423495
http://www.zhihu.com/collection/33423732
http://www.zhihu.com/collection/33424037
http://www.zhihu.com/collection/33424250
http://www.zhihu.com/collection/33424453
http://www.zhihu.com/collection/33424898
http://www.zhihu.com/collection/33426403
http://www.zhihu.com/collection/33427140
http://www.zhihu.com/collection/33427302
http://www.zhihu.com/collection/33427622
http://www.zhihu.com/collection/33427908
http://www.zhihu.com/collection/33428113
http://www.zhihu.com/collection/33428382
http://www.zhihu.com/collection/33428537
http://www.zhihu.com/collection/33428685
http://www.zhihu.com/collection/33428785
http://www.zhihu.com/collection/33428973
http://www.zhihu.com/collection/33429169
http://www.zhihu.com/collection/33429292
http://www.zhihu.com/collection/33429468
http://www.zhihu.com/collection/33429584
http://www.zhihu.com/collection/33429726
http://www.zhihu.com/collection/33426325
http://www.zhihu.com/collection/33426227
http://www.zhihu.com/collection/33426046
http://www.zhihu.com/collection/33426144
http://www.zhihu.com/collection/33425947
http://www.zhihu.com/collection/33425878
http://www.zhihu.com/collection/33425806

最新回复(0)
/jishuMnvn7LAFggGArrwtonCrZJ0s7uh6myEJVs2o9Q_3D_3D8