了笔试,面试的时候问什么问题一般问什么问题

>> [面试]HR最常用的20个面试问题及答案
[面试]HR最常用的20个面试问题及答案
来自前程无忧HR网友“HR女王”的分享:
&&&&根据在咨询中针对人事主管的调查,统计出20个人事主管最常问的问题和最喜欢的答案。
  我去应聘的时候,初试时我都会看这些问题,有些问题面试官的确会问,而我本人也做了有半年的初试官,也常会在面试时问起这些问题。
  问题1:你为什么想离开目前的职务?
  A.别的同仁认为我是老板前的红人,所以处处排挤我。
  B.调薪的结果令我十分失望,完全与我的付出不成正比。
  C.老板不愿授权,工作处处受限,绑手绑脚、很难做事。
  D.公司营运状况不佳,大家人心惶惶。
  解答:超过一半的人事主管选择C,其次为D。选择C的回答,可以显示应征者的企图心、能力强,且希望被赋予更多的职责。选择D,则是因离职原因为个人无法改变的客观外在因素,因此,面谈者也就不会对个人的能力或工作表现,有太多的存疑。
  问题2:你对我们公司了解有多少?
  A.贵公司在去年里,长达8个月的时间,都高居股王的宝座。
  B.贵公司连续3年被XX杂志评选为“求职者最想进入的企业”的第一名。
  C.不是很清楚,能否请您做些介绍。
  D.贵公司有意改变策略,加强与国外大厂的OEM合作,自有品牌的部分则透过海外经销商。
  解答:以D居多。道理很简单,他们希望求职者对所申请的工作有真正的了解,而不仅仅是慕名而来。
  问题3:你找工作时,最重要的考虑因素为何?
  A.公司的远景及产品竞争力。
  B.公司对员工生涯规划的重视及人性化的管理。
  C.工作的性质是否能让我发挥所长,并不断成长。
  D.合理的待遇及主管的管理风格。
  解答:以C居多,因为公司要找工作表现好、能够真正有贡献的人,而非纯粹慕名、求利而来的人。
  问题4:为什么我们应该录取你?
  A.因为我深信我比别人都优秀。
  B.因为我有很强烈的企图心,想要与贵公司共同成长。
  C.您可以由我过去的工作表现所呈现的客观数据,明显地看出我全力以赴的工作态度。
  D.我在这个产业已耕耘了8年,丰富的人脉是我最大的资产。
  解答:这题理想的回答是C。你如何让对方看到你的好?单凭口才,是很难令对方信服的,因此,从履历表内容或之前的回答内容中,如果能以客观数字、具体的工作成果,来辅助说明,是最理想的回答。
  问题5:请谈谈你个人的最大特色。
  A.我人缘极佳,连续3年担任福委会委员。
  B.我的坚持度很高,事情没有做到一个令人满意的结果,绝不罢手。
  C.我非常守时,工作以来,我从没有迟到过。
  D.我的个性很随和,是大家公认的好好先生。
  解答:这题理想的回答是B。A、C、D虽然都表示出应征者个性上的优点,但只有B的回答,最能和工作结合,能够与工作表现相结合的优点、特质,才是面谈者比较感兴趣的回答。
  问题6:“请你自我介绍一下”。
  思路:1、这是面试的必考题目。
  2、介绍内容要与个人简历相一致。
  3、表述方式上尽量口语化。
  4、要切中要害,不谈无关、无用的内容。
  5、条理要清晰,层次要分明。6、事先最好以文字的形式写好背熟。
  问题7:“谈谈你的家庭情况”
  思路:1、况对于了解应聘者的性格、观念、心态等有一定的作用,这是招聘单位问该问题的主要原因。
  2、简单地罗列家庭人口。
  3、宜强调温馨和睦的家庭氛围。
  4、宜强调父母对自己教育的重视。
  5、宜强调各位家庭成员的良好状况。
  6、宜强调家庭成员对自己工作的支持。
  7、宜强调自己对家庭的责任感。
  问题8:“你有什么业余爱好?”
  思路:1、业余爱好能在一定程度上反映应聘者的性格、观念、心态,这是招聘单位问该问题的主要原因。
  2、最好不要说自己没有业余爱好。
  3、不要说自己有那些庸俗的、令人感觉不好的爱好。
  4、最好不要说自己仅限于读书、听音乐、上网,否则可能令面试官怀疑应聘者性格孤僻。
  5、最好能有一些户外的业余爱好来“点缀”你的形象。
  问题9:“你最崇拜谁?”
  思路:1、最崇拜的人能在一定程度上反映应聘者的性格、观念、心态,这是面试官问该问题的主要原因。
  2、不宜说自己谁都不崇拜。
  3、不宜说崇拜自己。
  4、不宜说崇拜一个虚幻的、或是不知名的人。
  5、不宜说崇拜一个明显具有负面形象的人。
  6、所崇拜的人人最好与自己所应聘的工作能“搭”上关系。
  7、最好说出自己所崇拜的人的哪些品质、哪些思想感染着自己、鼓舞着自己。
  问题10:“你的座右铭是什么?”
  思路:1、座右铭能在一定程度上反映应聘者的性格、观念、心态,这是面试官问这个问题的主要原因。
  2、不宜说那些引起不好联想的座右铭。
  3、不宜说那些太抽象的座右铭。
  4、不宜说太长的座右铭。
  5、座右铭最好能反映出自己某种优秀品质。
  6、参考答案――“只为成功找方法,不为失败找借口”
  问题11:“谈谈你的缺点”
  思路:1、不宜说自己没缺点。
  2、不宜把那些明显的优点说成缺点。
  3、不宜说出严重影响所应聘工作的缺点。
  4、不宜说出令人不放心、不舒服的缺点。
  5、可以说出一些对于所应聘工作“无关紧要”的缺点,甚至是一些表面上看是缺点,从工作的角度看却是优点的缺点。
  问题12:“谈一谈你的一次失败经历”
  思路:1、不宜说自己没有失败的经历。
  2、不宜把那些明显的成功说成是失败。
  3、不宜说出严重影响所应聘工作的失败经历。
  4、所谈经历的结果应是失败的。
  5、宜说明失败之前自己曾信心白倍、尽心尽力。
  6、说明仅仅是由于外在客观原因导致失败。
  7、失败后自己很快振作起来,以更加饱满的热情面对以后的工作。
  问题13:“你为什么选择我们公司?”
  思路:1、面试官试图从中了解你求职的动机、愿望以及对此项工作的态度。
  2、建议从行业、企业和岗位这三个角度来回答。
  3、参考答案――“我十分看好贵公司所在的行业,我认为贵公司十分重视人才,而且这项工作很适合我,相信自己一定能做好。”
  问题14:“如果我录用你,你将怎样开展工作?”
  思路:1、如果应聘者对于应聘的职位缺乏足够的了解,最好不要直接说出自己开展工作的具体办法。
  2、可以尝试采用迂回战术来回答,如“首先听取领导的指示和要求,然后就有关情况进行了解和熟悉,接下来制定一份近期的工作计划并报领导批准,最后根据计划开展工作。”
  问题15:“与上级意见不一致时,你将怎么办?”
  思路:1、一般可以这样回答“我会给上级以必要的解释和提醒,在这种情况下,我会服从上级的意见。”
  2、如果面试你的是总经理,而你所应聘的职位另有一位经理,且这位经理当时不在场,可以这样回答:“对于非原则性问题,我会服从上级的意见,对于涉及公司利益的重大问题,我希望能向更高层领导反映。”“应届毕业生缺乏经验,如何能胜任工作?”
  问题16:“我们为什么要录用你?”
  思路:1、应聘者最好站在招聘单位的角度来回答。
  2、招聘单位一般会录用这样的应聘者:基本符合条件、对这份共组感兴趣、有足够的信心。
  3、如“我符合贵公司的招聘条件,凭我目前掌握的技能、高度的责任感和良好的饿适应能力及学习能力,完全能胜任这份工作。我十分希望能为贵公司服务,如果贵公司给我这个机会,我一定能成为贵公司的栋梁!”
  问题17:“你能为我们做什么?”
  思路:1、基本原则上“投其所好”。
  2、回答这个问题前应聘者最好能“先发制人”,了解招聘单位期待这个职位所能发挥的作用。
  3、应聘者可以根据自己的了解,结合自己在专业领域的优势来回答这个问题。
  问题18:“你是应届毕业生,缺乏经验,如何能胜任这项工作?”
  思路:1、如果招聘单位对应届毕业生的应聘者提出这个问题,说明招聘单位并不真正在乎“经验”,关键看应聘者怎样回答。
  2、对这个问题的回答最好要体现出应聘者的诚恳、机智、果敢及敬业。
  3、如“作为应届毕业生,在工作经验方面的确会有所欠缺,因此在读书期间我一直利用各种机会在这个行业里做兼职。我也发现,实际工作远比书本知识丰富、复杂。但我有较强的责任心、适应能力和学习能力,而且比较勤奋,所以在兼职中均能圆满完成各项工作,从中获取的经验也令我受益非浅。请贵公司放心,学校所学及兼职的工作经验使我一定能胜任这个职位。”
  问题19:“你希望与什么样的上级共事?”
  思路:1、通过应聘者对上级的“希望”可以判断出应聘者对自我要求的意识,这既上一个陷阱,又上一次机会。
  2、最好回避对上级具体的希望,多谈对自己的要求。
  3、如“做为刚步入社会新人,我应该多要求自己尽快熟悉环境、适应环境,而不应该对环境提出什么要求,只要能发挥我的专长就可以了。”
  问题20:“您在前一家公司的离职原因是什么?”
  思路:1、最重要的是:应聘者要使找招聘单位相信,应聘者在过往的单位的“离职原因”在此家招聘单位里不存在。
  2、避免把“离职原因”说得太详细、太具体。
  3、不能掺杂主观的负面感受,如“太幸苦”、“人际关系复杂”、“管理太混乱”、“公司不重视人才”、“公司排斥我们某某的员工”等。
  4、但也不能躲闪、回避,如“想换换环境”、“个人原因”等。
  5、不能涉及自己负面的人格特征,如不诚实、懒惰、缺乏责任感、不随和等。
  6、尽量使解释的理由为应聘者个人形象添彩。
  7、如“我离职是因为这家公司倒闭。我在公司工作了三年多,有较深的感情。从去年始,由于市场形势突变,公司的局面急转直下。到眼下这一步我觉得很遗憾,但还要面对,重新寻找能发挥我能力的舞台。”同一个面试问题并非只有一个答案,而同一个答案并不是在任何面试场合都有效,关键在于应聘者掌握了规律后,对面试的具体情况进行把握,有意识地揣摩面试官提出问题的心理背景,然后投其所好。(完)
-----------
欢迎关注微信订阅号“无忧求职锦囊”,下载“求职锦囊”APP
责权声明:本文所表述观点仅代表作者或发布者观点,与无关
同意,不得转载本网站之所有招聘信息及作品
未经51job同意,不得转载本网站之所有招聘信息及作品 | 无忧工作网版权所有&面试时经常会被问到的的问题 - CSDN博客
面试时经常会被问到的的问题
面试必备基础题目(虽然不一定常用, 仅用于面试, 面试就是把人搞的都不会然后砍价, 当然您可以讲我可以查资料完成, 但是面试的时候就是没道理的, 起码我是经常看到这些题).
如何把一段逗号分割的字符串转换成一个数组?request.getAttribute() 和 request.getParameter() 有何区别?response.sendRedirect() 和 forward() 区别?&%@include file=&xxx.jsp&%&和 &jsp:include& 区别?List 和 Map 区别?Struts 和 Spring 自动填充表单参数到 Bean 的大致原理?说一下你用的 Spring + Hibernate 的方框图? 您都用到了哪些部分?
请用英文简单介绍一下自己.
请把 &首页的这一段话用中文翻译一下?
Apache Tomcat is the servlet container that is used in the official Reference Implementation for the
technologies. The Java Servlet and JavaServer Pages specifications are developed by Sun under the .
Apache Tomcat is developed in an open and participatory environment and released under the . Apache Tomcat is intended to be a collaboration of the best-of-breed developers from around the world. We invite you to participate in this open development project. To learn more about getting involved, .
Apache Tomcat powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations. Some of these users and their stories are listed on the
wiki page.
try {Connection conn = ...;Statement stmt = ...;
ResultSet rs = stmt.executeQuery(&select * from table1&);
while(rs.next()) {
}} catch(Exception ex) {}
这段代码有什么不足之处?
HTML 的 form 提交之前如何验证数值不为空? 为空的话提示用户并终止提交?
为什么要用 ORM?& 和 JDBC 有何不一样?
Weblogic 的 Server, Machine, Node, Domain 都有何区别?
简要讲一下 EJB 的 7 个 Transaction Level?
最常见的: 用 JDBC 查询学生成绩单, 把主要代码写出来.
Tomcat 5 用 query.jsp?name=中文, 怎么把这个变量无乱码的取出来?
前几天有一个朋友去面试,被问到这样一个问题,如下
public class &smallT&2
public static void &main(String&args[])&4
{&5 &&&&&&&&smallT&t& = new &smallT();&6
int &b& = &t.get();&7 &&&&&&&&System.out.println(b);&8 &&&&}&9
public int &get()10
return 2 ;14 &&&&&&&&}15
catch (Exception&e)16
return 3 ;18 &&&&&&&&}19
return 4 ;22 &&&&&&&&}23 &&&&}24 }25
输出:4我记得学习的时候说有返回值的方法,执行完return语句后就会停止了;另一方面我还记得在try&&catch语句中finally语句也是一定要执行的。于是在这里就产生了麻烦。试了一下,发现果然是执行了finally中的值。正好这两天公司在培训,我便把这个问题提给java很厉害的一个讲师,他用断点测试了一下,说是两个值都返回了&&我又改了一小下,在get方法中逐个添上了输出信息到控制台的语句,发现居然能执行。如下
&1public class&test&2{&3 public static void&main(String&args[])&4{&5&&&&&&&&test&t&= new&test();&6 int&b&=&t.get();&7&&&&&&&&System.out.println(&Third:&a&=&&+b);&8&&&&}&9 public int&get()10{11 try12{13&&&&&&&&&System.out.println(&First:&a&=&&+2);14 return 2;15&&&&&&&&}16 catch(Exception&e)17{18&&&&&&&&&System.out.println(3);19&&&&&&&&}20 finally21{22&&&&&&&&&&&&System.out.println(&Second:&a&=&&+4);23 return 4;24&&&&&&&&}25&&&&}26}27
输出:First: a = 2Second: a = 4Third: a = 4可这明明是一个需要返回一个int整数的方法啊。
一个整数,大于0,不用循环和本地变量,按照n,2n,4n,8n的顺序递增,当值大于5000时,把值按照指定顺序输出来。例:n=1237则输出为:1237,2474,4948,9896,9896,4948,2474,1237,
1. Talk about overriding, overloading.2. Talk about JAVA design patterns you known.3. Talk about the difference between LinkList, ArrayList and Victor.4. Talk about the difference between an Abstract class and an Interface.5. Class a = new Class(); Class b = new Class();&if(a == b) returns true or false, why?6. Why we use StringBuffer when concatenating strings?7. Try to explain Singleton to us? Is it thread safe? If no, how to make it thread safe?8. Try to explain Ioc?9. How to set many-to-many relationship in Hibernate?10. Talk about the difference between INNER JOIN and LFET JOIN.11. Why we use index in database? How many indexes is the maximum in one table as your suggestion?12. When &Final& is used in class, method and property, what dose it mean?13. Do you have any experience on XML? Talk about any XML tool you used&,e.g. JAXB, JAXG.14. Do you have any experience on Linux?15. In OOD what is the reason when you create a Sequence diagram?
补一个内部培训用的 PPT:& &17KB, 英文, Sybase 调优, 大部分道理是通用的.
数据库三范式是什么? 别看问题简单, 我也经常答不上来被面试的人写上数据库不行.
还有就是 Sun Java 认证时候会考的一些英文选择题, 填空题,&模拟题也成.
也是上个星期五的上午,按照与猎头的约定,接受了香港某软件供应商的面试。工作是分析程序员,需赴港工作,以下是面试过程以及题目(大概记下了90%),记下来与大家分享。第一部分:例行公事的英文自我介绍;以下部分必须以粤语回答,本人非广东人,粤语会讲,但是不标准。第二部分:项目经验介绍,着重介绍项目背景,开发流程以及本人在项目开发过程中的角色;第三部分:面试官根据简历提问:(1)说出Abstract class与interface的不同?(2)Oracle中如何进行错误处理?如果用户反应速度慢,你如何着手解决问题?(3)图画板上列了两个table,问查询结果,主要是考inner join与left join的。(4)union和union all有什么不同?(5)你用什么软件做设计?(6)是否用过Websphere?(7)iBatis与Hibernate有什么不同?(8)谈谈Struts中的Action servlet。(9)是否开发过IBM portal项目。(10)是否介意加班?(11)如果你去香港工作,你认为你最大的困难是什么?第四部分:笔试,三个英文考试题目选一个作答,内容都是写一份email。出来后问了猎头,他说最迟一个星期内就有结果。结果,晚上就接到电话说通过了,并收到了合同和赴港申请的电子文件。工作地点是九龙,月薪18K(中等偏低),合同期一年。猎头催我尽快签合同,然后他们马上就去办工作签证。犹豫ing。
对于这个系列里的问题,每个学Java的人都应该搞懂。当然,如果只是学Java玩玩就无所谓了。如果你认为自己已经超越初学者了,却不很懂这些问题,请将你自己重归初学者行列。内容均来自于CSDN的经典老贴。问题一:我声明了什么!String&s&=&&Hello&world!&;许多人都做过这样的事情,但是,我们到底声明了什么?回答通常是:一个String,内容是&Hello&world!&。这样模糊的回答通常是概念不清的根源。如果要准确的回答,一半的人大概会回答错误。这个语句声明的是一个指向对象的引用,名为&s&,可以指向类型为String的任何对象,目前指向&Hello&world!&这个String类型的对象。这就是真正发生的事情。我们并没有声明一个String对象,我们只是声明了一个只能指向String对象的引用变量。所以,如果在刚才那句语句后面,如果再运行一句:String&string&=&s;我们是声明了另外一个只能指向String对象的引用,名为string,并没有第二个对象产生,string还是指向原来那个对象,也就是,和s指向同一个对象。问题二:&==&和equals方法究竟有什么区别?==操作符专门用来比较变量的值是否相等。比较好理解的一点是:int&a=10;int&b=10;则a==b将是true。但不好理解的地方是:String&a=new&String(&foo&);String&b=new&String(&foo&);则a==b将返回false。根据前一帖说过,对象变量其实是一个引用,它们的值是指向对象所在的内存地址,而不是对象本身。a和b都使用了new操作符,意味着将在内存中产生两个内容为&foo&的字符串,既然是&两个&,它们自然位于不同的内存地址。a和b的值其实是两个不同的内存地址的值,所以使用&==&操作符,结果会是 false。诚然,a和b所指的对象,它们的内容都是&foo&,应该是&相等&,但是==操作符并不涉及到对象内容的比较。对象内容的比较,正是equals方法做的事。看一下Object对象的equals方法是如何实现的:boolean&equals(Object&o){return&this==o;}Object 对象默认使用了==操作符。所以如果你自创的类没有覆盖equals方法,那你的类使用equals和使用==会得到同样的结果。同样也可以看出, Object的equals方法没有达到equals方法应该达到的目标:比较两个对象内容是否相等。因为答案应该由类的创建者决定,所以Object把这个任务留给了类的创建者。看一下一个极端的类:Class&Monster{private&String&...boolean&equals(Object&another){&return&}}我覆盖了equals方法。这个实现会导致无论Monster实例内容如何,它们之间的比较永远返回true。所以当你是用equals方法判断对象的内容是否相等,请不要想当然。因为可能你认为相等,而这个类的作者不这样认为,而类的equals方法的实现是由他掌握的。如果你需要使用equals方法,或者使用任何基于散列码的集合(HashSet,HashMap,HashTable),请察看一下 java&doc以确认这个类的equals逻辑是如何实现的。问题三:String到底变了没有?没有。因为String被设计成不可变(immutable)类,所以它的所有对象都是不可变对象。请看下列代码:String&s&=&&Hello&;s&=&s&+&&&world!&;s 所指向的对象是否改变了呢?从本系列第一篇的结论很容易导出这个结论。我们来看看发生了什么事情。在这段代码中,s原先指向一个String对象,内容是 &Hello&,然后我们对s进行了+操作,那么s所指向的那个对象是否发生了改变呢?答案是没有。这时,s不指向原来那个对象了,而指向了另一个 String对象,内容为&Hello&world!&,原来那个对象还存在于内存之中,只是s这个引用变量不再指向它了。通过上面的说明,我们很容易导出另一个结论,如果经常对字符串进行各种各样的修改,或者说,不可预见的修改,那么使用String来代表字符串的话会引起很大的内存开销。因为 String对象建立之后不能再改变,所以对于每一个不同的字符串,都需要一个String对象来表示。这时,应该考虑使用StringBuffer类,它允许修改,而不是每个不同的字符串都要生成一个新的对象。并且,这两种类的对象转换十分容易。同时,我们还可以知道,如果要使用内容相同的字符串,不必每次都new一个String。例如我们要在构造器中对一个名叫s的String引用变量进行初始化,把它设置为初始值,应当这样做:public&class&Demo&{private&String&s;...public&Demo&{s&=&&Initial&Value&;}...}而非s&=&new&String(&Initial&Value&);后者每次都会调用构造器,生成新对象,性能低下且内存开销大,并且没有意义,因为String对象不可改变,所以对于内容相同的字符串,只要一个String对象来表示就可以了。也就说,多次调用上面的构造器创建多个对象,他们的String类型属性s都指向同一个对象。上面的结论还基于这样一个事实:对于字符串常量,如果内容相同,Java认为它们代表同一个String对象。而用关键字new调用构造器,总是会创建一个新的对象,无论内容是否相同。至于为什么要把String类设计成不可变类,是它的用途决定的。其实不只String,很多Java标准类库中的类都是不可变的。在开发一个系统的时候,我们有时候也需要设计不可变类,来传递一组相关的值,这也是面向对象思想的体现。不可变类有一些优点,比如因为它的对象是只读的,所以多线程并发访问也不会有任何问题。当然也有一些缺点,比如每个不同的状态都要一个对象来代表,可能会造成性能上的问题。所以Java标准类库还提供了一个可变版本,即 StringBuffer。问题四:final关键字到底修饰了什么?final使得被修饰的变量&不变&,但是由于对象型变量的本质是&引用&,使得&不变&也有了两种含义:引用本身的不变,和引用指向的对象不变。引用本身的不变:final&StringBuffer&a=new&StringBuffer(&immutable&);final&StringBuffer&b=new&StringBuffer(&not&immutable&);a=b;//编译期错误引用指向的对象不变:final&StringBuffer&a=new&StringBuffer(&immutable&);a.append(&&broken!&);&//编译通过可见,final只对引用的&值&(也即它所指向的那个对象的内存地址)有效,它迫使引用只能指向初始指向的那个对象,改变它的指向会导致编译期错误。至于它所指向的对象的变化,final是不负责的。这很类似==操作符:==操作符只负责引用的&值&相等,至于这个地址所指向的对象内容是否相等,==操作符是不管的。理解final问题有很重要的含义。许多程序漏洞都基于此----final只能保证引用永远指向固定对象,不能保证那个对象的状态不变。在多线程的操作中,一个对象会被多个线程共享或修改,一个线程对对象无意识的修改可能会导致另一个使用此对象的线程崩溃。一个错误的解决方法就是在此对象新建的时候把它声明为final,意图使得它&永远不变&。其实那是徒劳的。问题五:到底要怎么样初始化!本问题讨论变量的初始化,所以先来看一下Java中有哪些种类的变量。1.&类的属性,或者叫值域2.&方法里的局部变量3.&方法的参数对于第一种变量,Java虚拟机会自动进行初始化。如果给出了初始值,则初始化为该初始值。如果没有给出,则把它初始化为该类型变量的默认初始值。int类型变量默认初始值为0float类型变量默认初始值为0.0fdouble类型变量默认初始值为0.0boolean类型变量默认初始值为falsechar类型变量默认初始值为0(ASCII码)long类型变量默认初始值为0所有对象引用类型变量默认初始值为null,即不指向任何对象。注意数组本身也是对象,所以没有初始化的数组引用在自动初始化后其值也是null。对于两种不同的类属性,static属性与instance属性,初始化的时机是不同的。instance属性在创建实例的时候初始化,static属性在类加载,也就是第一次用到这个类的时候初始化,对于后来的实例的创建,不再次进行初始化。这个问题会在以后的系列中进行详细讨论。对于第二种变量,必须明确地进行初始化。如果再没有初始化之前就试图使用它,编译器会抗议。如果初始化的语句在try块中或if块中,也必须要让它在第一次使用前一定能够得到赋值。也就是说,把初始化语句放在只有if块的条件判断语句中编译器也会抗议,因为执行的时候可能不符合if后面的判断条件,如此一来初始化语句就不会被执行了,这就违反了局部变量使用前必须初始化的规定。但如果在else块中也有初始化语句,就可以通过编译,因为无论如何,总有至少一条初始化语句会被执行,不会发生使用前未被初始化的事情。对于try-catch也是一样,如果只有在try块里才有初始化语句,编译部通过。如果在 catch或finally里也有,则可以通过编译。总之,要保证局部变量在使用之前一定被初始化了。所以,一个好的做法是在声明他们的时候就初始化他们,如果不知道要出事化成什么值好,就用上面的默认值吧!其实第三种变量和第二种本质上是一样的,都是方法中的局部变量。只不过作为参数,肯定是被初始化过的,传入的值就是初始值,所以不需要初始化。问题六:instanceof是什么东东?instanceof是Java的一个二元操作符,和==,&,&是同一类东东。由于它是由字母组成的,所以也是Java的保留关键字。它的作用是测试它左边的对象是否是它右边的类的实例,返回boolean类型的数据。举个例子:String&s&=&&I&AM&an&Object!&;boolean&isObject&=&s&instanceof&O我们声明了一个String对象引用,指向一个String对象,然后用instancof来测试它所指向的对象是否是Object类的一个实例,显然,这是真的,所以返回true,也就是isObject的值为True。instanceof有一些用处。比如我们写了一个处理账单的系统,其中有这样三个类:public&class&Bill&{//省略细节}public&class&PhoneBill&extends&Bill&{//省略细节}public&class&GasBill&extends&Bill&{//省略细节}在处理程序里有一个方法,接受一个Bill类型的对象,计算金额。假设两种账单计算方法不同,而传入的Bill对象可能是两种中的任何一种,所以要用instanceof来判断:public&double&calculate(Bill&bill)&{if&(bill&instanceof&PhoneBill)&{//计算电话账单}if&(bill&instanceof&GasBill)&{//计算燃气账单}...}这样就可以用一个方法处理两种子类。然而,这种做法通常被认为是没有好好利用面向对象中的多态性。其实上面的功能要求用方法重载完全可以实现,这是面向对象变成应有的做法,避免回到结构化编程模式。只要提供两个名字和返回值都相同,接受参数类型不同的方法就可以了:public&double&calculate(PhoneBill&bill)&{//计算电话账单}public&double&calculate(GasBill&bill)&{//计算燃气账单}所以,使用instanceof在绝大多数情况下并不是推荐的做法,应当好好利用多态。
BeanSoft 参加过的一次面试:
日 星期三 〖农历 甲申 猴年 七月初三〗
笔试题目1. 写出常用的 Linux 命令a) 列出当前目录b) 列出所有系统变量c) 重命名文件d) etc... 记不住了.
2. Write a Java application use the Singleton pattern, it should have one instance per class. It should have two integer variable, one is count, on is inita. There should be two methods in this class, and the method should be thread safely in multi-thread environment.a) a count() method, after each call the count should be added on by 1;b) a reset() method, after each call the count should be set to the value of inita.
3. Write a JavaBean and a JSP file. The page should output a date string in this pattern &今天是日上午10:00&, the value is taken from the bean.
4. 以下三个题目, 任选其一或多个:1) 忘了..., 是关于 Java 的.2) 写一个应用程序, 读出 STUDENT 表中的数据并打印出所有名称. 数据库系统任选.3) 写一个 Servlet, 读取名为 url 的参数, 并连接到此字符串指定的地址上, 读取所有内容后显示给客户.
5. 6. 7. 都是关于 SQL 的, 例如 SELECT, UPDATE, DELETE 之类的, 还有的有子查询. 数据库系统没有限制.
8. Write a html file, it shoud has follow functions:1) check whether the user'2) the email address should has a '@';3) telephone number must be '1'-'9', '-', ' '(space).Page picture:Please input your name:[____________________] [Check input]Please input your address:[abc@________________] [Check input]Please input your telephone number:[____123a____________] [Check input]
Java 面试题及其答案
前段时间因为要参加一个笔试,在准备期间在网上找到了两条关于笔试题目的文章,其中一篇为&&有感:应聘Java笔试时可能出现问题&&,还有一篇忘了名字,读后深受启发。 在寻找这些答案的过程中,我将相关答案记录下来,就形成了以下这些东西。需要说明的是以下答案肯定有很多不完整甚至错误的地方,需要各位来更正与完善它,千万不要扔我的鸡蛋啊。 希望本文能够给即将奔赴笔试考场的同仁些许帮助,更希望更多的人加入到收集整理笔试题与完善答案的这些工作中来,为大家更好的获得工作机会做一点贡献。 在此感谢前面两文的作者的对笔试题目的收集与整理。 如有任何意见与建议请通过QQ:6045306,Mail:与我联系。 Java基础方面:
1、作用域public,private,protected,以及不写时的区别 答:区别如下: 作用域 当前类 同一package 子孙类 其他package public & & & & protected & & & & friendly & & & & private & & & & 不写时默认为friendly
2、ArrayList和Vector的区别,HashMap和Hashtable的区别 答:就ArrayList与Vector主要从二方面来说. 一.同步性:Vector是线程安全的,也就是说是同步的,而ArrayList是线程序不安全的,不是同步的 二.数据增长:当需要增长时,Vector默认增长为原来一培,而ArrayList却是原来的一半 就HashMap与HashTable主要从三方面来说。 一.历史原因:Hashtable是基于陈旧的Dictionary类的,HashMap是Java 1.2引进的Map接口的一个实现 二.同步性:Hashtable是线程安全的,也就是说是同步的,而HashMap是线程序不安全的,不是同步的 三.值:只有HashMap可以让你将空值作为一个表的条目的key或value
3、char型变量中能不能存贮一个中文汉字?为什么? 答:是能够定义成为一个中文的,因为java中以unicode编码,一个char占16个字节,所以放一个中文是没问题的
4、多线程有几种实现方法,都是什么?同步有几种实现方法,都是什么? 答:多线程有两种实现方法,分别是继承Thread类与实现Runnable接口 同步的实现方面有两种,分别是synchronized,wait与notify
5、继承时候类的执行顺序问题,一般都是选择题,问你将会打印出什么? 答:父类:
public class FatherClass { public FatherClass() { System.out.println(&FatherClass Create&); } } 子类:
import test.FatherC public class ChildClass extends FatherClass { public ChildClass() { System.out.println(&ChildClass Create&); } public static void main(String[] args) { FatherClass fc = new FatherClass(); ChildClass cc = new ChildClass(); } } 输出结果: C:/&java test.ChildClass FatherClass Create FatherClass Create ChildClass Create
6、内部类的实现方式? 答:示例代码如下:
public class OuterClass { private class InterClass { public InterClass() { System.out.println(&InterClass Create&); } } public OuterClass() { InterClass ic = new InterClass(); System.out.println(&OuterClass Create&); } public static void main(String[] args) { OuterClass oc = new OuterClass(); } } 输出结果: C:/&java test/OuterClass InterClass Create OuterClass Create 再一个例题: public class OuterClass { private double d1 = 1.0; //insert code here } You need to insert an inner class declaration at line 3. Which two inner class declarations are
valid?(Choose two.) A. class InnerOne{ public static double methoda() {return d1;} } B. public class InnerOne{ static double methoda() {return d1;} } C. private class InnerOne{ double methoda() {return d1;} } D. static class InnerOne{ protected double methoda() {return d1;} } E. abstract class InnerOne{ public abstract double methoda(); } 说明如下: 一.静态内部类可以有静态成员,而非静态内部类则不能有静态成员。 故 A、B 错 二.静态内部类的非静态成员可以访问外部类的静态变量,而不可访问外部类的非静态变量;return d1 出错。
故 D 错 三.非静态内部类的非静态成员可以访问外部类的非静态变量。 故 C 正确 四.答案为C、E
7、垃圾回收机制,如何优化程序? 希望大家补上,谢谢
8、float型float f=3.4是否正确? 答:不正确。精度不准确,应该用强制类型转换,如下所示:float f=(float)3.4
9、介绍JAVA中的Collection FrameWork(包括如何写自己的数据结构)? 答:Collection FrameWork如下: Collection ├List │├LinkedList │├ArrayList │└Vector │ └Stack └Set Map ├Hashtable ├HashMap └WeakHashMap Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements) Map提供key到value的映射
10、Java中异常处理机制,事件机制?
11、JAVA中的多形与继承? 希望大家补上,谢谢
12、抽象类与接口? 答:抽象类与接口都用于抽象,但是抽象类(JAVA中)可以有自己的部分实现,而接口则完全是一个标识(同时有多重继承的功能)。
13、Java 的通信编程,编程题(或问答),用JAVA SOCKET编程,读服务器几个字符,再写入本地显示? 答:Server端程序:
import java.net.*; import java.io.*;
public class Server { private ServerS private S private BufferedR private PrintW public Server() { try { ss=new ServerSocket(10000); while(true) { socket = ss.accept(); String RemoteIP = socket.getInetAddress().getHostAddress(); String RemotePort = &:&+socket.getLocalPort(); System.out.println(&A client come in!IP:&+RemoteIP+RemotePort); in = new BufferedReader(new
InputStreamReader(socket.getInputStream())); String line = in.readLine(); System.out.println(&Cleint send is :& + line); out = new PrintWriter(socket.getOutputStream(),true); out.println(&Your Message Received!&); out.close(); in.close(); socket.close(); } }catch (IOException e) { out.println(&wrong&); } } public static void main(String[] args) { new Server(); } }; Client端程序:
import java.io.*; import java.net.*;
public class Client { S BufferedR PrintW public Client() { try { System.out.println(&Try to Connect to 127.0.0.1:10000&); socket = new Socket(&127.0.0.1&,10000); System.out.println(&The Server Connected!&); System.out.println(&Please enter some Character:&); BufferedReader line = new BufferedReader(new
InputStreamReader(System.in)); out = new PrintWriter(socket.getOutputStream(),true); out.println(line.readLine()); in = new BufferedReader(new InputStreamReader(socket.getInputStream())); System.out.println(in.readLine()); out.close(); in.close(); socket.close(); }catch(IOException e) { out.println(&Wrong&); } } public static void main(String[] args) { new Client(); } };
14、用JAVA实现一种排序,JAVA类实现序列化的方法(二种)? 如在COLLECTION框架中,实现比较要实现什么样的接口? 答:用插入法进行排序代码如下
import java.util.*; class InsertSort { ArrayL public InsertSort(int num,int mod) { al = new ArrayList(num); Random rand = new Random(); System.out.println(&The ArrayList Sort Before:&); for (int i=0;i&i++ ) { al.add(new Integer(Math.abs(rand.nextInt()) % mod + 1)); System.out.println(&al[&+i+&]=&+al.get(i)); } } public void SortIt() { Integer tempI int MaxSize=1; for(int i=1;i&al.size();i++) { tempInt = (Integer)al.remove(i); if(tempInt.intValue()&=((Integer)al.get(MaxSize-1)).intValue()) { al.add(MaxSize,tempInt); MaxSize++; System.out.println(al.toString()); } else { for (int j=0;j&MaxSj++ ) { if
(((Integer)al.get(j)).intValue()&=tempInt.intValue()) { al.add(j,tempInt); MaxSize++; System.out.println(al.toString());
} } } } System.out.println(&The ArrayList Sort After:&); for(int i=0;i&al.size();i++) { System.out.println(&al[&+i+&]=&+al.get(i)); } } public static void main(String[] args) { InsertSort is = new InsertSort(10,100); is.SortIt(); } } JAVA类实现序例化的方法是实现java.io.Serializable接口 Collection框架中实现比较要实现Comparable 接口和 Comparator 接口
15、编程:编写一个截取字符串的函数,输入为一个字符串和字节数,输出为按字节截取的字符串。 但是要保证汉字不被截半个,如&我ABC&4,应该截为&我AB&,输入&我ABC汉DEF&,6,应该输出为&我ABC&而不是&我ABC+汉的半个&。 答:代码如下:
class SplitString { String SplitS int SplitB public SplitString(String str,int bytes) { SplitStr= SplitByte= System.out.println(&The String is:&&+SplitStr+&&SplitBytes=&+SplitByte); } public void SplitIt() { int loopC
loopCount=(SplitStr.length()%SplitByte==0)?(SplitStr.length()/SplitByte):(SplitStr.length()/Split
Byte+1); System.out.println(&Will Split into &+loopCount); for (int i=1;i&=loopCi++ ) { if (i==loopCount){
System.out.println(SplitStr.substring((i-1)*SplitByte,SplitStr.length())); } else {
System.out.println(SplitStr.substring((i-1)*SplitByte,(i*SplitByte))); } } } public static void main(String[] args) { SplitString ss = new SplitString(&test中dd文dsaf中男大3443n中国43中国人
0ewldfls=103&,4); ss.SplitIt(); } }
16、JAVA多线程编程。 用JAVA写一个多线程程序,如写四个线程,二个加1,二个对一个变量减一,输出。 希望大家补上,谢谢
17、STRING与STRINGBUFFER的区别。 答:STRING的长度是不可变的,STRINGBUFFER的长度是可变的。如果你对字符串中的内容经常进行操作,特别是内容要修改时,那么使用StringBuffer,如果最后需要String,那么使用StringBuffer的toString()方法
1、jsp有哪些内置对象?作用分别是什么? 答:JSP共有以下9种基本内置组件(可与ASP的6种内部组件相对应):  request 用户端请求,此请求会包含来自GET/POST请求的参数 response 网页传回用户端的回应 pageContext 网页的属性是在这里管理 session 与请求有关的会话期 application servlet 正在执行的内容 out 用来传送回应的输出 config servlet的构架部件 page JSP网页本身 exception 针对错误网页,未捕捉的例外
2、jsp有哪些动作?作用分别是什么? 答:JSP共有以下6种基本动作 jsp:include:在页面被请求的时候引入一个文件。 jsp:useBean:寻找或者实例化一个JavaBean。 jsp:setProperty:设置JavaBean的属性。 jsp:getProperty:输出某个JavaBean的属性。 jsp:forward:把请求转到一个新的页面。 jsp:plugin:根据浏览器类型为Java插件生成OBJECT或EMBED标记
3、JSP中动态INCLUDE与静态INCLUDE的区别? 答:动态INCLUDE用jsp:include动作实现 &jsp:include page=&included.jsp& flush=&true& /&它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数 静态INCLUDE用include伪码实现,定不会检查所含文件的变化,适用于包含静态页面 &%@ include file=&included.htm& %&
4、两种跳转方式分别是什么?有什么区别? 答:有两种,分别为: &jsp:include page=&included.jsp& flush=&true&& &jsp:forward page= &nextpage.jsp&/& 前者页面不会转向include所指的页面,只是显示该页的结果,主页面还是原来的页面。执行完后还会回来,相当于函数调用。并且可以带参数.后者完全转向新页面,不会再回来。相当于go to 语句。
Servlet方面
1、说一说Servlet的生命周期? 答:servlet有良好的生存期的定义,包括加载和实例化、初始化、处理请求以及服务结束。这个生存期由javax.servlet.Servlet接口的init,service和destroy方法表达。
2、Servlet版本间(忘了问的是哪两个版本了)的不同? 希望大家补上,谢谢
3、JAVA SERVLET API中forward() 与redirect()的区别? 答:前者仅是容器中控制权的转向,在客户端浏览器地址栏中不会显示出转向后的地址;后者则是完全的跳转,浏览器将会得到跳转的地址,并重新发送请求链接。这样,从浏览器的地址栏中可以看到跳转后的链接地址。所以,前者更加高效,在前者可以满足需要时,尽量使用forward()方法,并且,这样也有助于隐藏实际的链接。在有些情况下,比如,需要跳转到一个其它服务器上的资源,则必须使用sendRedirect()方法。
4、Servlet的基本架构 public class ServletName extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
Jdbc、Jdo方面
1、可能会让你写一段Jdbc连Oracle的程序,并实现数据查询. 答:程序如下: package hello. import java.sql.*; public class jdbc { String dbUrl=&jdbc:oracle:thin:@127.0.0.1:1521:orcl& String theUser=&admin& String thePw=&manager& Connection c= S ResultSet rs= public jdbc() { try{ Class.forName(&oracle.jdbc.driver.OracleDriver&).newInstance(); c = DriverManager.getConnection(dbUrl,theUser,thePw); conn=c.createStatement(); }catch(Exception e){ e.printStackTrace(); } } public boolean executeUpdate(String sql) { try { conn.executeUpdate(sql);
} catch (SQLException e) { e.printStackTrace();
} } public ResultSet executeQuery(String sql) { rs= try { rs=conn.executeQuery(sql); } catch (SQLException e) { e.printStackTrace(); }
} public void close() { try { conn.close(); c.close(); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] args) { ResultS jdbc conn = new jdbc(); rs=conn.executeQuery(&select * from test&); try{ while (rs.next()) { System.out.println(rs.getString(&id&)); System.out.println(rs.getString(&name&)); } }catch(Exception e) { e.printStackTrace(); } } }
2、Class.forName的作用?为什么要用? 答:调用该访问返回一个以字符串指定类名的类的对象。
3、Jdo是什么? 答:JDO是Java对象持久化的新的规范,为java data object的简称,也是一个用于存取某种数据仓库中的对象的标准化API。JDO提供了透明的对象存储,因此对开发人员来说,存储数据对象完全不需要额外的代码(如JDBC API的使用)。这些繁琐的例行工作已经转移到JDO产品提供商身上,使开发人员解脱出来,从而集中时间和精力在业务逻辑上。另外,JDO很灵活,因为它可以在任何数据底层上运行。JDBC只是面向关系数据库(RDBMS)JDO更通用,提供到任何数据底层的存储功能,比如关系数据库、文件、XML以及对象数据库(ODBMS)等等,使得应用可移植性更强。
4、在ORACLE大数据量下的分页解决方法。一般用截取ID方法,还有是三层嵌套方法。 答:一种分页方法 &% int i=1; int numPages=14; String pages = request.getParameter(&page&) ; int currentPage = 1; currentPage=(pages==null)?(1):{Integer.parseInt(pages)} sql = &select count(*) from tables& ResultSet rs = DBLink.executeQuery(sql) ; while(rs.next()) i = rs.getInt(1) ; int intPageCount=1; intPageCount=(i%numPages==0)?(i/numPages):(i/numPages+1); int nextP int upP nextPage = currentPage+1; if (nextPage&=intPageCount) nextPage=intPageC upPage = currentPage-1; if (upPage&=1) upPage=1; rs.close(); sql=&select * from tables& rs=DBLink.executeQuery(sql); i=0; while((i&numPages*(currentPage-1))&&rs.next()){i++;} %& //输出内容 //输出翻页连接 合计:&%=currentPage%&/&%=intPageCount%&&a href=&List.jsp?page=1&&第一页&/a&&a
href=&List.jsp?page=&%=upPage%&&&上一页&/a& &% for(int j=1;j&=intPageCj++){ if(currentPage!=j){ %& &a href=&list.jsp?page=&%=j%&&&[&%=j%&]&/a& &% }else{ out.println(j); } } %& &a href=&List.jsp?page=&%=nextPage%&&&下一页&/a&&a href=&List.jsp?page=&%=intPageCount%&&&最后页
1、xml有哪些解析技术?区别是什么? 答:有DOM,SAX,STAX等 DOM:处理大型文件时其性能下降的非常厉害。这个问题是由DOM的树结构所造成的,这种结构占用的内存较多,而且DOM必须在解析文件之前把整个文档装入内存,适合对XML的随机访问SAX:不现于DOM,SAX是事件驱动型的XML解析方式。它顺序读取XML文件,不需要一次全部装载整个文件。当遇到像文件开头,文档结束,或者标签开头与标签结束时,它会触发一个事件,用户通过在其回调事件中写入处理代码来处理XML文件,适合对XML的顺序访问 STAX:Streaming API for XML (StAX)
2、你在项目中用到了xml技术的哪些方面?如何实现的? 答:用到了数据存贮,信息配置两方面。在做数据交换平台时,将不能数据源的数据组装成XML文件,然后将XML文件压缩打包加密后通过网络传送给接收者,接收解密与解压缩后再同XML文件中还原相关信息进行处理。在做软件配置时,利用XML可以很方便的进行,软件的各种配置参数都存贮在XML文件中。
3、用jdom解析xml文件时如何解决中文问题?如何解析? 答:看如下代码,用编码方式加以解决
import java.io.*; public class DOMTest { private String inFile = &c://people.xml& private String outFile = &c://people.xml& public static void main(String args[]) { new DOMTest(); } public DOMTest() { try { javax.xml.parsers.DocumentBuilder builder =
javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); org.w3c.dom.Document doc = builder.newDocument(); org.w3c.dom.Element root = doc.createElement(&老师&); org.w3c.dom.Element wang = doc.createElement(&王&); org.w3c.dom.Element liu = doc.createElement(&刘&); wang.appendChild(doc.createTextNode(&我是王老师&)); root.appendChild(wang); doc.appendChild(root); javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, &gb2312&); transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, &yes&);
transformer.transform(new javax.xml.transform.dom.DOMSource(doc), new
javax.xml.transform.stream.StreamResult(outFile)); } catch (Exception e) { System.out.println (e.getMessage()); } } }
4、编程用JAVA解析XML的方式. 答:用SAX方式解析XML,XML文件如下: &?xml version=&1.0& encoding=&gb2312&?& &person& &name&王小明&/name& &college&信息学院&/college& &telephone&6258113&/telephone& &notes&男,1955年生,博士,95年调入海南大学&/notes& &/person& 事件回调类SAXHandler.java import java.io.*; import java.util.H import org.xml.sax.*; public class SAXHandler extends HandlerBase { private Hashtable table = new Hashtable(); private String currentElement = private String currentValue = public void setTable(Hashtable table) { this.table = } public Hashtable getTable() {
} public void startElement(String tag, AttributeList attrs) throws SAXException { currentElement = } public void characters(char[] ch, int start, int length) throws SAXException { currentValue = new String(ch, start, length); } public void endElement(String name) throws SAXException { if (currentElement.equals(name)) table.put(currentElement, currentValue); } } JSP内容显示源码,SaxXml.jsp: &HTML& &HEAD& &TITLE&剖析XML文件people.xml&/TITLE& &/HEAD& &BODY& &%@ page errorPage=&ErrPage.jsp& contentType=&text/charset=GB2312& %& &%@ page import=&java.io.*& %& &%@ page import=&java.util.Hashtable& %& &%@ page import=&org.w3c.dom.*& %& &%@ page import=&org.xml.sax.*& %& &%@ page import=&javax.xml.parsers.SAXParserFactory& %& &%@ page import=&javax.xml.parsers.SAXParser& %& &%@ page import=&SAXHandler& %& &% File file = new File(&c://people.xml&); FileReader reader = new FileReader(file); P SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); SAXHandler handler = new SAXHandler(); sp.parse(new InputSource(reader), handler); Hashtable hashTable = handler.getTable(); out.println(&&TABLE BORDER=2&&CAPTION&教师信息表&/CAPTION&&); out.println(&&TR&&TD&姓名&/TD&& + &&TD&& + (String)hashTable.get(new String(&name&)) + &&/TD&&/TR&&); out.println(&&TR&&TD&学院&/TD&& + &&TD&& + (String)hashTable.get(new String(&college&))+&&/TD&&/TR&&); out.println(&&TR&&TD&电话&/TD&& + &&TD&& + (String)hashTable.get(new String(&telephone&)) + &&/TD&&/TR&&); out.println(&&TR&&TD&备注&/TD&& + &&TD&& + (String)hashTable.get(new String(&notes&)) + &&/TD&&/TR&&); out.println(&&/TABLE&&); %& &/BODY& &/HTML&
1、EJB2.0有哪些内容?分别用在什么场合? EJB2.0和EJB1.1的区别? 答:规范内容包括Bean提供者,应用程序装配者,EJB容器,EJB配置工具,EJB服务提供者,系统管理员。这里面,EJB容器是EJB之所以能够运行的核心。EJB容器管理着EJB的创建,撤消,激活,去活,与数据库的连接等等重要的核心工作。JSP,Servlet,EJB,JNDI,JDBC,JMS.....
2、EJB与JAVA BEAN的区别? 答:Java Bean 是可复用的组件,对Java Bean并没有严格的规范,理论上讲,任何一个Java类都可以是一个Bean。但通常情况下,由于Java Bean是被容器所创建(如Tomcat)的,所以Java Bean应具有一个无参的构造器,另外,通常Java Bean还要实现Serializable接口用于实现Bean的持久性。Java Bean实际上相当于微软COM模型中的本地进程内COM组件,它是不能被跨进程访问的。Enterprise Java Bean 相当于DCOM,即分布式组件。它是基于Java的远程方法调用(RMI)技术的,所以EJB可以被远程访问(跨进程、跨计算机)。但EJB必须被布署在诸如Webspere、WebLogic这样的容器中,EJB客户从不直接访问真正的EJB组件,而是通过其容器访问。EJB容器是EJB组件的代理,EJB组件由容器所创建和管理。客户通过容器来访问真正的EJB组件。
3、EJB的基本架构 答:一个EJB包括三个部分: Remote Interface 接口的代码 package B import javax.ejb.EJBO import java.rmi.RemoteE public interface Add extends EJBObject { //some method declare } Home Interface 接口的代码 package B import java.rmi.RemoteE import jaax.ejb.CreateE import javax.ejb.EJBH public interface AddHome extends EJBHome { //some method declare } EJB类的代码 package B import java.rmi.RemoteE import javax.ejb.SessionB import javx.ejb.SessionC public class AddBean Implements SessionBean { //some method declare }
J2EE,MVC方面
1、MVC的各个部分都有那些技术来实现?如何实现? 答:MVC是Model-View-Controller的简写。&Model& 代表的是应用的业务逻辑(通过JavaBean,EJB组件实现), &View& 是应用的表示面(由JSP页面产生),&Controller& 是提供应用的处理过程控制(一般是一个Servlet),通过这种设计模型把应用逻辑,处理过程和显示逻辑分成不同的组件实现。这些组件可以进行交互和重用。
2、应用服务器与WEB SERVER的区别? 希望大家补上,谢谢
3、J2EE是什么? 答:Je22是Sun公司提出的多层(multi-diered),分布式(distributed),基于组件(component-base)的企业级应用模型(enterpriese application model).在这样的一个应用系统中,可按照功能划分为不同的组件,这些组件又可在不同计算机上,并且处于相应的层次(tier)中。所属层次包括客户层(clietn tier)组件,web层和组件,Business层和组件,企业信息系统(EIS)层。
4、WEB SERVICE名词解释。JSWDL开发包的介绍。JAXP、JAXM的解释。SOAP、UDDI,WSDL解释。 答:Web Service描述语言WSDL SOAP即简单对象访问协议(Simple Object Access Protocol),它是用于交换XML编码信息的轻量级协议。 UDDI 的目的是为电子商务建立标准;UDDI是一套基于Web的、分布式的、为Web Service提供的、信息注册中心的实现标准规范,同时也包含一组使企业能将自身提供的Web Service注册,以使别的企业能够发现的访问协议的实现标准。
5、BS与CS的联系与区别。 希望大家补上,谢谢
6、STRUTS的应用(如STRUTS架构) 答:Struts是采用Java Servlet/JavaServer Pages技术,开发Web应用程序的开放源码的framework。 采用Struts能开发出基于MVC(Model-View-Controller)设计模式的应用构架。 Struts有如下的主要功能: 一.包含一个controller servlet,能将用户的请求发送到相应的Action对象。 二.JSP自由tag库,并且在controller servlet中提供关联支持,帮助开发员创建交互式表单应用。 三.提供了一系列实用对象:XML处理、通过Java reflection APIs自动处理JavaBeans属性、国际化的提示和消息。
设计模式方面
1、开发中都用到了那些设计模式?用在什么场合? 答:每个模式都描述了一个在我们的环境中不断出现的问题,然后描述了该问题的解决方案的核心。通过这种方式,你可以无数次地使用那些已有的解决方案,无需在重复相同的工作。主要用到了MVC的设计模式。用来开发JSP/Servlet或者J2EE的相关应用。简单工厂模式等。
2、UML方面 答:标准建模语言UML。用例图,静态图(包括类图、对象图和包图),行为图,交互图(顺序图,合作图),实现图,
JavaScript方面
1、如何校验数字型? var re=/^/d{1,8}$|/./d{1,2}$/; var str=document.form1.all(i). var r=str.match(re); if (r==null) { sign=-4;
} else{ document.form1.all(i).value=parseFloat(str); }
1、CORBA是什么?用途是什么? 答:CORBA 标准是公共对象请求代理结构(Common Object Request Broker Architecture),由对象管理组织 (Object Management Group,缩写为 OMG)标准化。它的组成是接口定义语言(IDL), 语言绑定(binding:也译为联编)和允许应用程序间互操作的协议。 其目的为: 用不同的程序设计语言书写 在不同的进程中运行 为不同的操作系统开发
1、LINUX下线程,GDI类的解释。 答:LINUX实现的就是基于核心轻量级进程的&一对一&线程模型,一个线程实体对应一个核心轻量级进程,而线程之间的管理在核外函数库中实现。 GDI类为图像设备编程接口类库。
Hibernate: 简述 Hibernate 和 JDBC 的优缺点? 如何书写一个 one to many 配置文件.
Spring 的依赖注入是什么意思? 给一个 Bean 的 message 属性, 字符串类型, 注入值为 &Hello& 的 XML 配置文件该怎么写?SCJP 模拟题200道附答案Q1 Which of the following statements are valid, given the following variable declarations: 1) (a | b) 2)(a || a) 3)(a ^ b) | c 4)(a & c) 5)(a && c)
Q2 Which of the following can be applied to constructors: 1) final 2) static 3) synchronized 4) native 5) None of these.
Q3 Which of the following retain their preferred size (width and height) when added (individually) to the North section of a container with a BorderLayout (assume that no other components or containers are present in the North section). 1) TextArea 2) Button 3) TextField 4) Checkbox 5) None. All of these mentioned components will only retain their preferred height.
Q4 Which of the following are legal names for variables. 1) _int 2) %large 3) $fred 4) Integer 5) 2much
Q5 Which of the following are correct ways to create a font. 1) Font f = new Font(&Serif&, Font.BOLD, 24); 2) Font f = new Font(Font.SERIF, &Bold&, 24); 3) Font f = new Font(&Serif&, &Bold&, 24); 4) Font f = new Font(Font.SERIF, Font.BOLD, 24);
Q6 Select the correct statements regarding the following piece of code. File f = new File(&c://large.txt&); 1) On execution, a file called &large.txt& will be created on the local harddisk. 2) The code fails to compile on a UNIX machine, because the directory separator is not correct. 3) A file is NOT created on the harddisk when this code is executed. 4) An exception is thrown at runtime if the file &large.txt& already exists. 5) The code fails to compile, since this is not a valid constructor for the File class.
Q7 Which of the following statements are correct regarding the RandomAccessFile class? 1) An IOException is thrown if the specified file doesn't exist when created using the &r& mode. 2) This class has a method which allows a file to be deleted from the harddisk. 3) It is possible to use this class in conjunction with the DataInputStream class. 4) When used with the &rw& mode, the specified file is created on a diskdrive, if it doesn't already exist. 5) There are methods to read and write primatives (eg, readInt(), writeInt(), etc).
Q8 Consider the following piece of code and select the correct statement from the following. 1.String s = new String(&abcdefgh&); 2.s.replace('d', 'q'); 3.System.out.println(s);
1) The code fails to compile, reporting an error at line 2. Strings are immutable, and therefore a replace() method is meaningless. 2) The code compiles correctly, and displays the text &abcqefgh&. 3) The code compiles correctly, and displays the text &abcdefgh&. 4) The code compiles, but an exception is thrown when line 2 is executed. 5) The code compiles, but an exception is thrown at line 3.
Q9 Which of the following keywords can be applied to the variables or methods of an interface. 1) static 2) private 3) synchronised 4) protected 5) public
Q10 True or False. Only Frames can contain menu bars or pull-down menus. 1) True 2) False.
Q11 Consider the following piece of code and select the correct statement(s): 1. class A{ 2. protected int method(){ 3. } 4. } 5. 6. class B extends A{ 7. int method(){ 8. } 9. } 1) The code fails to compile, because you can't override a method to be more private than its parent. 2) The code fails to compile, because method() is declared as protected, and is therefore not available to any subclass. 3) The code compiles correctly, but throws a NullPointerException at runtime. 4) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier &public&. 5) The code fails to compile. However, it can be made to compile correctly by prefixing line 7 with the access qualifier &protected&.
Q12 True or False.
The Throwable class is the superclass of all exceptions in the Java language. 1) True 2) False
Q13 Consider the following piece of code (assume the Graphics context g is defined correctly): g.setBackground(Color.red); g.setForeground(Color.white); g.drawLine(10, 10, 50, 10); g.setForeground(Color.blue); g.drawRect(100, 100, 50, 50);
What is displayed when this code is executed. 1) A blue line from (10,10) to (50,10) and a blue rectangle with upper left corner at (100,100). 2) A white line from (10,10) to (50,10) and a blue square with top left corner at (100,100). 3) A white line from (10,10) to (10,50) and a blue square with lower left corner at (100,100). 4) A red line from (10, 10) to (50,10) and a red square with upper left corner at (100,100). 5) Nothing is displayed. You must first issue a repaint() command.
Q14 Consider the following piece of code. class Test{ public static void main(String [] args){ System.out.println(args[3]); } } When the following is typed at the command line, what is displayed: java Test Metallica Justice For All 1) All 2) For 3) Justice 4) Nothing. 5) Nothing. An ArrayIndexOutOfBoundsException is thrown
Q15 Consider the following piece of code. 1. String s = &abcd&; 2. Integer x = new Integer(3); 3. String s2 = s + 4; 4. s2 = 5. s =
Following the execution of which line above, is the object referenced by s2 available for garbage collection. 1) Line 5 2) It is not possible to say when an object is available for garbage collection. 3) Line 4 4) The objects are not available until the executing thread is ended.
Q16 What is displayed when the following piece of code is compiled and executed: class Test{ public static void main(String [] args){ Base b = new Subclass(); System.out.println(b.x); System.out.println(b.method()); } }
class Base{ int x = 2; int method(){
class Subclass extends Base{ int x = 3; int method(){
1) Nothing. The code fails to compile because the object b is not created in a valid way. 2) 2 3 3) 2 2 4) 3 3 5) 3 2
Q17 What is displayed when the following is executed: String s1 = &aaa&; s1.concat(&bbb&); System.out.println(s1); 1) The string &aaa&. 2) The string &aaabbb&. 3) Nothing. concat() is not a valid method in the String class. 4) The string &bbbaaa&. 5) The string &bbb&.
Q18 True or False. The following is a valid way to construct a StringBuffer. StringBuffer sb1 = &abcd&; 1) True 2) False
Q19 What is the output of the following piece of code: 1. int x = 6; 2. double d = 7.7; 3. 4. System.out.println((x & d) ? 99.9 : 9);
1) 9 2) 9.0 3) 99.9 4) Nothing. An ArithmeticException is thrown at line 4. 5) 6
Q20 Which of the following can be put in applet tags? (select all the correct answers) 1) CODE 2) WIDTH 3) HEIGHT 4) PARAM 5) ARCHIVE
Q21 What is printed out following the execution of the code below: 1. class Test{ 2. static S 3. public static void main(String []args){ 4. int x = 4; 5. if (x & 4) 6. System.out.println(&Val = & + x); 7. else 8. System.out.println(s); 9. } 10. } Nothing. The code fails to compile because the String s isn't declared correctly. 1) The text &Val = null& is displayed. 2) The string &Val = & is displayed. 3) The text &null& is displayed. 4) A blank line of text is printed.
Q22 True or False. The StringBuffer class does not have a concat() method. 1) True 2) False
Q23 What is displayed when the following piece of code is executed (assume the graphics context, g, is correctly set up): g.drawString(&abc&, 10, 10); 1) The text &abc& with the lower left part of &a& located at x = 10, y = 10. 2) The text &abc& with the upper left part of &a& located at x = 10, y = 10. 3) Nothing. This is not a valid method.
Q24 True or False. Anonymous classes cannot have constructors. 1) True 2) False
Q25 To reference a JAR from a web page, which of the following keywords are used: 1) jar 2) class 3) zip 4) archive 5) package
Analyse the following 2 classes and select the correct statements. class A{ private int x = 0; static int y = 1; protected int q = 2; }
class B extends A{ void method(){ System.out.println(x); System.out.println(y); System.out.println(q); } }
1) The code fails to compile because the variable x is not available to class B. 2) The code compiles correctly, and the following is displayed: 0 1 2 3) The code fails to compile because you can't subclass a class with private variables. 4) Removing the line &System.out.println(x)& will allow the code to compile correctly. 5) The compiler will complain that the variable x in class B is undefined.
Q27 Which of the following interfaces can be used to manage a collection of elements, with no duplication. 1) List 2) Vector 3) Set
Q28 Which of the following statements are true regarding inner classes. 1) Variables defined inside inner classes cannot be static. 2) Variables defined inside inner classes cannot be static unless the inner class itself is static. 3) Non-static inner classes (which are not defined in a method) have access to all class and instance variables, regardless of the access qualifier of those variables. 4) An inner class can actually be a subclass of the outer class 5) Inner classes can be declared as private. Top level, outer classes cannot.
Q29 Which of the following are valid ways to define an abstract method. 1) abstract void Test(); 2) abstract void Test() {} 3) static abstract void Test(); 4) final abstract void Test(); 5) Methods cannot be defined as abstract, only variables can be abstract.
Q30 Consider the following: class A extends Integer{ int x = 0; } Select all valid statements. 1) The code will compile correctly. 2) The code will not compile because Integer is final and cannot be subclassed. 3) The code will not compile because class A has no methods or constructor. 4) The code will compile correctly, but will throw an ArithmeticException at runtime.
Q31 Consider the following and select the correct statement(s): interface A{ int x = 0; A(){ x= 5; } A(int s){ x = } } 1) This is a valid piece of code and it compiles correctly. 2) The default constructor is not required since the compiler will create one for you. 3) The code fails to compile because interfaces cannot have more than 1 constructor. 4) The code fails to compile because an interface cannot have any constructors. 5) The code fails to compile, because a class must have more than 1 character in it's name.
Q32 True or False. A try block always needs a catch or a finally block (either or both, but not none). 1) True 2) False
Q33 Which of the following are valid ways to declare the main() method which is used to start a Java program. 1) public static void main(String [] args) 2) static public void main(String [] args) 3) public void main(String args []) 4) public static void main(String args[]) 5) public static void main(String args)
Q34 Consider the following piece of code: boolean b = System.out.println(b); What is displayed when this code is executed? 1) The text &true& is displayed. 2) The text &1& is displayed 3) The code fails to compile, because conversion string conversion in ths System.out.println() method only applies to integers. 4) The code compiles but nothing is displayed upon execution. 5) The code fails to compile. However, changing the first line to &boolean b = TRUE;& will correctly declare a boolean, and the code will compile and display &TRUE&.
Q35 Which of the following pieces of code compiles without any errors? 1) StringBuffer sb1 = &abcd&; 2) Boolean b = new Boolean(&abcd&); 3) byte b = 255; 4) int x = 0x1234; 5) float fl = 1.2;
Q36 Which of the following are valid statements regarding the following piece of code? 1. String s1 = &abcd&; 2. StringBuffer sb1 = new StringBuffer(&abcd&); 3. int val = 6; 4. System.out.println(s1 + val); 5. System.out.println(sb1 + val);
1) The text &abcd6& is displayed followed by &abcd6&. 2) The code fails to compile because String conversion does not apply to StringBuffer. 3) The code compiles but upon execution, throws a NullPointerException at line 5. 4) The code fails to compile at line 2, because this is not a valid way to create a StringBuffer. 5) The code fails to compile at line 1, because this is not a valid way to create a String.
Q37 True or False. Abstract methods can be declared as static. 1) True 2) False
Q38 FlowLayout is the default layout manager for which of the following containers: 1) Panel 2) Applet 3) Frame 4) Window 5) Dialog
Q39 In which class are the following methods defined: - wait() - notify() - notifyAll() 1) Thread 2) Runnable 3) Object 4) Event 5) Synchronize
Q40 Which one of the following creates an instance of Vector with an initial capacity of 10, and an incremental capacity of 5. 1) new Vector(10, 5); 2) new Vector(5,10); 3) None. There is no constructor of Vector which provides this feature. 4) Vector is declared as final, and it is therefore not possible to instantiate it.
Q41 True of False. CheckboxGroup is a subclass of Component. 1) True 2) False
Q42 Which statements(s) below are true about the following piece of code. class Test implements Runnable{ public static void main(String [] args){ Thread t = new Thread(new Test()); t.start(); }
public void run(int limit){ for (int x = 0; x & x++) System.out.println(x); } }
1) All the numbers up to (but not including) &limit& are printed out. 2) Nothing is displayed. There is no explicit call to the run() method. 3) The code fails to compile because the Runnable interface is not implemented correctly. 4) The code can be made to compile by declaring the class Test to be abstract. 5) The code can be made to compile by removing the words &implements Runnable&.
Q43 Consider the following code and select the statement(s) which are true: 1. class Test extends Frame{ 2. 3. public static void main(String [] args){ 4. Test t = new Test(); 5. } 6. 7. Test(){ 8. Button b = new Button(&Hello&); 9. add(b, BorderLayout.SOUTH); 10. } 11. 12. }
1) The code compiles. When executed, nothing is displayed. 2) The code compiles. When executed, a button with the text &Hello& is located at the bottom on the screen. The button is as tall as the text, but is the width of the frame. 3) Adding in the following two lines between lines 9 and 10 will display a frame with a button at the bottom of the frame: setSize(100, 100); setVisible(true); 4) The code fails to compile, because a layout manager was not specified. 5) The code fails to compile because you cannot subclass the Frame class.
Q44 Before which of the following can the keyword &synchronized& be placed, without causing a compile error. 1) class methods 2) instance methods 3) any block of code within a method 4) variables 5) a class
Q45 Consider the following class definitions: class Base{} class Subclass1 extends Base{} class Subclass2 extends Base(); Now consider the following declarations: Base b = new Base(); Subclass1 s1 = new Subclass1(); Subclass2 s2 = new Subclass2(); Now, consider the following assignment: s1 = (Subclass1)s2; Which of the following statements are correct regarding this assignment (select one). 1) The assignment is legal and compiles without an error. No exception is thrown at runtime. 2) The code fails to compile. The compiler complains that the assignment &s1 = (Subclass1)s2& is illegal. 3) The code compiles but ClassCastException is thrown at runtime. 4) The code fails to compile. You cannot subclass a parent class more than once.
Q46 Select all the valid ways of initialising an array. 1) int x[] = {1,2,3}; 2) int []x[] = {{1,2,3},{1,2,3}}; 3) int x[3] = {1,2,3}; 4) int []x = {0,0,0}; 5) char c[] = {'a', 'b'};
Q47 What is the valid declaration for the finalize() method. 1) protected void finalize() throws Throwable 2) final finalize() 3) public final finalize() 4) private boolean finalize() 5) private final void finalize() throws Exception
Q48 What is the method used to retrieve a parameter passed into an applet using the PARAM tag. 1) getParam() 2) getParameter() 3) getVariable() 4) getVar() 5) There is no method available. You must use &String [] args& approach.
Q49 You have a button, which is in a panel. The panel is inside a frame. You assign the Frame a 24-point font and a background colour of yellow. You set the panel to have a background colour of red. Which of the following statements are true (select all valid statements). 1) The font size of the button is 24-point. 2) The background colour of the button is the same as that of the frame. 3) The panel has a font size of 8-point. 4) The button inherits the font from the panel. 5) This is not a valid configuration. It is not valid to place a panel into a frame.
Q50 Consider the following piece of code and select the correct statement(s): public class Test{ final int x = 0; Test(){ x = 1; } final int aMethod(){
1) The code fails to compile. The compiler complains because there is a final method (&aMethod&) in a non-final class. 2) The code compiles correctly. On execution, an exception is thrown when the Test() constructor is executed. 3) The code fails to compile because an attempt is made to alter the value of a final variable. 4) Removing the &final& keyword from the line &final int x = 0& will allow the code to compile correctly. 5) The code fails to compile because only methods can be declared as final (and therefore &final int x = 0& is not valid).
Q51 What is displayed when the following code fragment is compiled and executed (assume that the enveloping class and method is correctly declared and defined): StringBuffer sb1 = new StringBuffer(&abcd&); StringBuffer sb2 = new StringBuffer(&abcd&); String s1 = new String(&abcd&); String s2 = &abcd&; System.out.println(s1==s2); System.out.println(s1=s2); System.out.println(sb1==sb2); System.out.println(s1.equals(sb1)); System.out.println(sb1.equals(sb2));
1) The code fails to compile, complaining that the line System.out.println(s1=s2); is illegal. 2) The code fails to compile because the equals() method is not defined for the StringBuffer class. 3) false true true false false 4) false abcd false false false 5) false true false false true
Q52 What is the default layout manager for applets and panels? 1) FlowLayout 2) BorderLayout 3) GridBagLayout 4) GridLayout 5) None of these
Q53 Which of the following statements will compile without an error? 1) Boolean b = new Boolean(&abcd&); 2) float f = 123; 3) byte b = 127; 4) int x = (int)(1.23); 5) short s = 128;
Q54 True or False. Menus can be added to containers. 1) True 2) False
Q55 Which of the following statements are true regarding the graphical methods paint(), repaint() and update(). 1) paint() schedules a call to repaint(). 2) repaint() schedules a call to update(). 3) update() calls paint(). 4) update() schedules a call to repaint(). 5) repaint() calls paint() directly.
Q56 To which of the following can a menubar component be added? 1) Applet 2) Panel 3) Frame 4) Canvas
Q57 With regard to apply applet by HTML tags, which of the following statements are correct? 1) The CODE, WIDTH and HEIGHT tags are mandatory and the order is insignificant. 2) CODE and CODEBASE are case insensitive, and the .class extension is optional. 3) The PARAM tag is case insensitive. 4) It is possible to download multiple JAR's with the ARCHIVE tag (eg, ARCHIVE = &a.jar, b.jar&). 5) The CODE tag is the only mandatory tag.
Q58 Consider the following piece of code and select the correct statements. 1. Object o = new String(&abcd&); 2. String s = 3. System.out.println(s); 4. System.out.println(o);
1) The following is displayed: abcd abcd 2) The code fails to compile at line 1. 3) The code fails to compile at line 2 4) The code fails to compile at line 4. 5) The code can be made to compile by changing line 1 to the following: String o = new String(&abcd&);
Q59 Which of the following are legal methods for the String class? 1) length() 2) toUpper() 3) toUpperCase() 4) toString() 5) equals()
Q60 What is the output from the following piece of code: loop1: for(int i = 0; i & 3; i++){ loop2: for(int j = 0; j & 3; j++){ if (i == j){ break loop2; } System.out.print(&i = & + i + & j = & + j + & &); } }
1) i = 1 j = 0 2) i = 1 j = 0 i = 2 j = 1 3) i = 0 j = 1 i = 0 j = 2 i = 1 j = 0 i = 2 j = 0 i = 2 j = 1 4) i = 1 j = 0 i = 2 j = 0 i = 2 j = 1 5) i = 1 j = 0 i = 2 j = 0 i = 2 j = 1
Q61 What is displayed when the following piece of code is executed: loop1: for(int i = 0; i & 3; i++){ loop2: for(int j = 0; j & 3; j++){ if (i == j){ continue loop2; } System.out.println(&i = & + i + & j = & + j); } }
1) i = 0 j = 0 i = 0 j = 1 i =

我要回帖

更多关于 游戏运营笔试问题 的文章

 

随机推荐