面试题目
(1)string a='hello' string b = new String ('hello') char c= 'hello' StringBuffer d=new StringBuffer('hello'); 然后 abcd 的equal ==关系 了解好string 的存储 堆栈存储的东西这个题目不会有问题 a==b a.equal(b)
(2) int i=0; try { i++ throw new Exception (); }(catch Exception ){ i++ } (finally) {i++} sysout(i) 输出i值多少
(3) class AException extends Excption{} try { throw new AException(); } catch(AException ){ sysout('a') } catch(AException ){ sysout('b') } 然后看输出的结果 应该只有a 当时我打错了。
(4)String a= "hello" 然后4选项选个对的,这个我当时记得认为B是不对,查了下 A,char c= a; B,int i =a.length;
(5)
int a,b,c,d =0; if(((a=3)>0)||(b=3)>0){} if(((c=3)>0|(d=3)>0){}
然后输出abcd 应该是 3033 b短路了走不到,这题开始没看明白,做下题的是偶瞟了一眼才想明白的呵呵,
(6) Aclass {field x}; Bclass extends Aclass {field x , field y}; Cclass extend Bclass {field x };
然后new一个Aclass a , BClass b , cclass c对象 访问abc的 xy 属性 了解继承应该不会出问题
(7)hibernate的 一对多问题,如customer order (1:n关系) 给你一段xml配置一对多的代码,然后 调用1方的获取多方的方法 list a= cousomer.getOrderset() for(order o : a){ sysout (1); } 然后问结果样式 应该是11111……,用过hibernate 应该知道,
(8) String a = new String(); string b=a; String c= new String(); 问一共创建了几个对象。
(9)class ClassA{ static int num =0;
public int a; ClassA(){ a=number++;)
}