




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2024年Java认证笔试历年真题荟萃含答案(图片大小可自由调整)第1卷一.参考题库(共30题)1.11. double input = 314159.26; 12. NumberFormat nf= NumberFormat.getInstance(Locale.ITALIAN); 13. String b; 14. //insert code here Which code, inserted at line 14, sets the value of b to 3 14.159,26?() A、 b = nf.parse( input);B、 b = nf.format( input);C、 b = nf.equals( input);D、 b = nf.parseObject( input);2. And MainClass exists in the /apps/com/company/application directory. Assume the CLASSPATH environment variable is set to "." (current directory).Which two java commands entered at the command line will run MainClass?()A、java MainClass if run from the /apps directoryB、java pany.application.MainClass if run from the /apps directoryC、java -classpath /apps pany.application.MainClass if run from any directoryD、java-classpath . MainClass if run from the /apps/com/company/application directoryE、java -classpath /apps/com/company/application:. MainClass if run from the /apps directoryF、java pany.application.MainClass if run from the /apps/com/company/application directory3.Given an HttpServlet Request request and Http Servlet Response response, which sets a cookie “username” with the value “joe” in a servlet.?()A、 request.add Cookie (“username”. “joe”)B、 request.set Cookie (“username, “joe”)C、 response.add Cookie (username”, “joe”))D、 request.add Header (new Cookie (“username”, “joe”))E、 request.add Cookie (new Cookie (“username”, “joe”))F、 response.add Cookie (new Cookie (“username”, “joe”))G、 response.add Header (new Cookie (“username”, “joe”))4.有关new关键字的描述正确的是哪项?() A、创建对象实例的时候可以不使用new关键字B、new所创建的对象不占用内存空间C、new会调用类的构造器来创建对象D、new所创建的对象一定存在引用变量5.现有: class Test4 { public static void main (String [] args) { boolean X=true; boolean y=false; short Z=42; if((z++==42) && (y=true))z++; if((x=false) || (++z==45)) z++; System. out.println(¨z=”+z); } } 结果为:() A、 Z=42B、 z=44C、 Z= 45D、 z= 466.1. class Calc { 2. public static void main(String [] args) { 3. try { 4. int x = Integer.parseInt("42a"); 5. //insert code here 6. System.out.print("oops "); 7. } 8. } 9. } 下面哪两行分别插入到第五行,会导致输出“oops”?()A、} catch (ClassCastException c) {B、} catch (IllegalStateException c) {C、} catch (NumberFormatException n) {D、} catch (IllegalArgumentException e) {7. For a given product instance, which three jsp:setProperty attributes must be used to initialized its properties form the HTML form? ()A、 idB、 nameC、 typeD、 paramE、 propertyF、 reqParamG、 attribute8.public void test(int x) { int odd = x%2; if (odd) { System.out.println(“odd); } else { System.out.println(“even”); } } Which statement is true?() A、Compilation fails.B、 “odd” will always be output.C、 “even” will always be output.D、 “odd” will be output for odd values of x, and “even” for even values.E、 “even” will be output for add values of x, and “odd” for even values.9.java接口的方法修饰符可以为()。(忽略内部接口)A、privateB、protectedC、finalD、abstract10.现有 import java.io.PrintWriter; class DoFormat{ public static void main (String [] args) { int x=42; int y=12345; float Z-7 ; System.out.format("一%4d-", X); System. out.format("-%4d-", y); System. out.format("-%4.ld-",z); } } 结果为:() A、编译失败B、 -42- -1234- -7.0-C、 - 42- -1234- -7.0-D、 - 42- -12345- -7.0-E、运行时异常被抛出11.public class Test { public static void main(String [] args) { boolean assert = true; if(assert) { System.out.println(”assert is true”); } } } Given: javac -source 1.3 Test.java What is the result?() A、 Compilation fails.B、 Compilation succeeds with errors.C、 Compilation succeeds with warnings.D、 Compilation succeeds without warnings or errors.12.You are developing several tag libraries that will be sold for development of third-party web applications.You are about to publish the first three libraries as JAR files: container-tags.jar,advanced-html-form-tags.jar, and basic-html-form-tags.jar. Which two techniques are appropriate for packaging the TLD files forthese tag libraries?()A、The TLD must be located within the WEB-INF directory of the JAR file.B、The TLD must be located within the META-INF directory of the JAR file.C、The TLD must be located within the META-INF/tld/ directory of the JAR file.D、The TLD must be located within a subdirectory of WEB-INF directory of the JAR file.E、The TLD must be located within a subdirectory of META-INF directory of the JAR file.13.AnInterface is an interface. AnAdapter0 is a non-abstract, non-final class with a zero argument constructor. AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument. Which two construct an anonymous inner class?() A、AnAdapter1 aa=new AnAdapter1(){}B、AnAdapter0 aa=new AnAdapter0(){}C、AnAdapter0 aa=new AnAdapter0(5){}D、AnAdapter1 aa=new AnAdapter1(5){}E、AnInterface a1=new AnInterface(5){}14.现有: class Thread2 implements Runnable { void run() { System.out.print("go "); } public static void main(String [] args) { Thread2 t2 = new Thread2(); Thread t = new Thread(t2); t.start(); } } 结果为:()A、 goB、 编译失败C、 代码运行,无输出结果D、 运行时异常被抛出15.You have created a servlet that generates weather maps. The data for these maps is calculated by aremote host. The IP address of this host is usually stable, but occasionally does have to change as thecorporate network grows and changes. This IP address used to be hard coded, but after the fifth change tothe IP address in two years, you have decided that this value should be declared in the deploymentdescriptor so you do NOT have the recompile the web application every time the IP address changes. Which deployment descriptor snippet accomplishes this goal?()A、B、C、D、16.子类可以继承父类的除私有成员以外的其它所有成员。17.A JSP page needs to set the property of a given JavaBean to a value that is calculated with the JSP page. Which three jsp:setProperty attributes must be used to perform this initialization?()A、IdB、ValC、NameD、ParamE、ValueF、Property18.11.classSnoochy{ 12.Boochybooch; 13.publicSnoochy(){booch=newBoochy(this);} 14.} 15. 16.classBoochy{ 17.Snoochysnooch; 18.publicBoochy(Snoochys){snooch=s;} 19.} Andthestatements: 21.publicstaticvoidmain(String[]args){ 22.Snoochysnoog=newSnoochy(); 23.snoog=null; 24.//morecodehere 25.} Whichstatementistrueabouttheobjectsreferencedbysnoog,snooch,andboochimmediatelyafterline23executes?()A、Noneoftheseobjectsareeligibleforgarbagecollection.B、Onlytheobjectreferencedbyboochiseligibleforgarbagecollection.C、Onlytheobjectreferencedbysnoogiseligibleforgarbagecollection.D、Onlytheobjectreferencedbysnoochiseligibleforgarbagecollection.E、Theobjectsreferencedbysnoochandboochareeligibleforgarbagecollection.19.Which four statments are true?() A、Raccoon is-a Mammal.B、Raccoon has-a Mammal.C、BabyRaccoon is-a Mammal.D、BabyRaccoon is-a Raccoon.E、BabyRaccoon has-a Mammal.F、BabyRaccoon is-a BabyRaccoon.20.将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。 程序分析:对n进行分解质因数,应先找到一个最小的质数k,然后按下述步骤完成: (1)如果这个质数恰等于n,则说明分解质因数的过程已经结束,打印出即可。 (2)如果n k,但n能被k整除,则应打印出k的值,并用n除以k的商,作为新的正整数你n,重复执行第一步。 (3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步。21.选出不正确的叙述()。A、死锁是指因相互竞争资源使得系统中有多个阻塞进程的情况B、若系统中并发运行的进程和资源之间满足互斥条件、占有且申请、不可抢占和环路条件,则可判定系统中发生了死锁C、在对付死锁的策略中,解除死锁通常都是和检测死锁配套使用D、产生死锁的原因可归结为竞争资源和进程推进顺序不当E、在死锁的解决方法中,由于避免死锁采用静态分配资源策略,所以对资源的利用率不高22.11.publicstaticvoidmain(String[]args){ 12.Objectobj=newint[]{1,2,3}; 13.int[]someArray=(int[])obj; 14.for(inti:someArray)System.out.print(i+"") 15.} Whatistheresult?()A、123B、Compilationfailsbecauseofanerrorinline12.C、Compilationfailsbecauseofanerrorinline13.D、Compilationfailsbecauseofanerrorinline14.E、AClassCastExceptionisthrownatruntime.23.设有方法: 则b可以为()A、nullB、b的类型为AC、b的类型为A的子类D、b的类型为A的父类24.以下涉及到内存管理的代码段中,有错误的是:()。 A、AB、BC、CD、D25.A developer wants a web application to be notified when the application is about to be shut down. Whichtwo actions are necessary to accomplish this goal?()A、Include a listener directive in a JSP pageB、configure a listener in the TLD file using the elementC、Include a element in the web application deployment descriptorD、configure a listener in the application deployment descriptor, using the elementE、Include a class implementing ServletContextListener as part of the web application deploymen26.运行时,数组以哪种方式存在?() A、对象 B、基本类型变量 C、引用类型变量 D、视具体情况而定27.以下哪个不是Collection的子接口()A、 ListB、 SetC、 MapD、 SortedSet28.线程安全的map在JDK1.5及其更高版本环境有哪几种方法可以实现()。A、Map map = new HashMap()B、Map map = new TreeMap()C、Map map = new ConcurrentHashMap()D、Map map = Collections.synchronizedMap(new HashMap())29.interface Altitude { //insert code here } 和4个声明: int HIGH = 7; public int HIGH = 7; abstract int HIGH = 7; interface int HIGH = 7; 分别插入到第2行,有多少行可以编译?() A、 0B、 1C、 2D、 3E、 430.A developer is designing the presentation tier for a web application that relies on a complex session bean.The session bean is still being developed and the APIs for it are NOT finalized. Any changes to the sessionbean API directly impacts the development of the presentation tier. Which design pattern provides a meansto manage the uncertainty in the API?()A、View HelperB、Front ControllerC、Composite ViewD、Intercepting FilterE、Business Delegate第1卷参考答案一.参考题库1.参考答案:B2.参考答案:B,C3.参考答案:F4.参考答案:C5.参考答案:D6.参考答案:C,D7.参考答案:A,D,G8.参考答案:A9.参考答案:D10.参考答案:E11.参考答案:C12.参考答案:B,E13.参考答案:B,D14.参考答案:B15.参考答案:D16.参考答案:正确17.参考答案:C,E,F18.参考答案:E19.参考答案:A,B,C,F20.参考答案:21.参考答案:A,B22.参考答案:A23.参考答案:A,B,C24.参考答案:A,B,D25.参考答案:D,E26.参考答案:A27.参考答案:C28.参考答案:C,D29.参考答案:C30.参考答案:E第2卷一.参考题库(共30题)1.如何引用包中的某个类?如何引用整个包?如果编写JavaApplet程序时想把整个java.applet包都加载,则应该怎么做?2.javax.swing.Timer将按一定频率产生什么事件()A、ActionEventB、TimerEventC、ItemEventD、InputEvent3.Click the ’Select and Place’ button. Place the events in the order they occur. 4.Which is a benefit of precompiling a JSP page?()A、It avoids initialization on the first request.B、It provides the ability to debug runtime errors in the application.C、It provides better performance on the first request for the JSP page.D、It avoids execution of the _jspService method on the first request.5.For which three events can web application event listeners be registered?()A、When a session is createdB、After a servlet is destroyedC、When a session has timed outD、When a cookie has been createdE、When a servlet has forwarded a requestF、When a session attribute value is changed6.现有:D - f 是一个对 java.io.File 实例的合法引用 - fw 是一个对 java.io.FileWriter 实例的合法引用 - bw 是一个对 java.io.BufferedWriter 实例的合法引用 以下哪一项无效?() A、 PrintWriter prtWtr = new PrintWriter(f);B、 PrintWriter prtWtr = new PrintWriter(fw);C、 PrintWriter prtWtr = new PrintWriter(bw);D、 BufferWriter bufWtr = new BufferedWriter(f);E、 BufferWriter bufWtr = new BufferedWriter(fw);F、 BufferWriter bufWtr = new BufferedWriter(bw);7.实例方法是根据引用变量的声明类型进行访问的8.A developer for the C web site has been told that users may turn off cookie support in their browsers. What must the developer do to ensure that these customers can still use the web application?() A、 The developer must ensure that every URL is properly encoded using the appropriate URL rewriting APIsB、 The developer must provide an alternate mechanism for managing sessions and abandon theHttpSession mechanism entirelyC、 The developer can ignore this issue. Web containers are required to support automatic URL rewriting when cookies are not supportedD、 The developer must ass the string ?id= to the end of every URL to ensure that the conversion with the browser can continue.9.You are writing a JSP that includes scriptlet code to declare a List variable and initializes that variable to anArrayList object. Which two JSP code snippets can you use to import these list types?()A、B、C、D、E、F、10.拍七游戏打印出"拍七"游戏规则:大家依次从1开始顺序数数,数到含有7或7的倍数的要拍手或其它规定的方式表示越过(比如:7,14,17等都不能数出),下一人继续数下面的数字。违反规则者受罚。11.HTTP中的POST和GET在下列哪些方面有区别()。A、数据位置B、明文密文C、数据安全D、长度限度E、应用场景12.求四位的水仙花数。即满足这样条样的四位数:各位数字的4次方和等于该数自身。13.窗口监听器有哪些特点?()A、可以继承窗口适配器(WindowAdapter)类,并覆写其中需要用到的函数B、窗口监听器所实现的接口是WindowListener,它有多?个函数C、窗口监听器可以只实现WindowListener接口中的一两个函数D、响应窗口打开,关闭,最小化成图标,由图标还原,激活,无效,最大化,还原,获取焦点,失去作业点等事件E、仅在Windows操作系统下有效14.下面哪个类不能直接读取磁盘文件()A、FileReaderB、RandomAccessFileC、FilterReaderD、FileInputStream15.1. int I=1, j=0 2. 3. switch(i) { 4. case 2: 5. j+=6; 6. 7. case 4: 8. j+=1; 9. 10. default: 11. j +=2; 12. 13. case 0: 14. j +=4; 15. } 16. What is the value of j at line 16?()A、 0B、 1C、 2D、 4E、 616.Which four are true?()A、 Has-a relationships should never be encapsulated.B、 Has-a relationships should be implemented using inheritance.C、 Has-a relationships can be implemented using instance variables.D、 Is-a relationships can be implemented using the extends keyword.E、 Is-a relationships can be implemented using the implements keyword.F、 An array or a collection can be used to implement a one-to-many has-a relationship.G、 The relationship between Movie and Actress is an example of an is-a relationship.17.内存垃圾回收将删除无法访问的对象18.What is the result?() A、Compilation fails.B、Cannot add ToppingsC、The code runs with no output.D、A NullPointerException is thrown in Line 14.19.What will be written to the standard output when the following program is run?() public class Q8499 { public static void main(String args[]) { double d = -2.9; int i = (int) d; i *= (int) Math.ceil(d); i *= (int) Math.abs(d); System.out.println(i); } }A、12B、18C、8D、9E、2720.为将数组myArray的长度由6改为10,现采取以下编码: int[] myArray = new int[6]; myArray = new int[10]; 代码执行后,以下叙述哪项是正确的?() A、 数组myArray的长度已由6改为10,其中前6个元素的值不变,后四个元素的值为空。B、 数组myArray的长度已由6改为10,其中前6个元素的值不变,后四个元素需再经过初始化后才能使用。C、 数组myArray的长度已由6改为10,原来6个元素的值全部丢失。D、 数组myArray的长度没有变化。21.public class Threads2 implements Runnable { public void nun() { System.out.println(”run.”); throw new RuntimeException(”Problem”); } public static void main(String[] args) { Thread t = new Thread(new Threads2()); t.start(); System.out.println(”End of method.”); } } Which two can be results?()A、 java.lang.RuntimeException: ProblemB、 run.
java.lang.RuntimeException: ProblemC、 End of method.
java.lang.RuntimeException: ProblemD、 End of method.
run.
java.lang.RuntimeException: ProblemE、 run.
java.lang.RuntimeException: Problem
End of method.22.java中,用()关键字定义常量。A、finalB、#defineC、floatD、const23.A C developer is designing the presentation tier for a web application that relies on a complex session bean. The session bean is still being developed and the APIs for are NOT finalized. Any changes to the session bean API directly impacts the development of the presentation tier. Which design pattern provides a means to manage the uncertainty in the API?()A、 View HelperB、 Front ControllerC、 Composite ViewD、 Intercepti
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 劳动合同劳务合同范例
- 公司合并协议合同范本
- 全职合同范本
- 医院物业招聘合同范本
- 加盟快递押金合同范本
- 单位电线更换维修合同范本
- 声学顾问合同范本
- 单位车棚工程合同范本
- cpvc管购买合同范本
- ul认证合同范本
- 高中主题班会 悟哪吒精神做英雄少年-下学期开学第一课主题班会课件-高中主题班会课件
- 2025电力物资检储配一体化建设技术导则
- 新学期 开学第一课 主题班会课件
- 民法典合同编讲座
- 2024年青岛港湾职业技术学院高职单招语文历年参考题库含答案解析
- 广西壮族自治区公路发展中心2025年面向社会公开招聘657名工作人员高频重点提升(共500题)附带答案详解
- 大学转专业高等数学试卷
- DBJ51-T 198-2022 四川省既有民用建筑结构安全隐患排查技术标准
- 公司厂区保洁培训
- 江苏省招标中心有限公司招聘笔试冲刺题2025
- 2024年防盗门销售合同范本
评论
0/150
提交评论