收藏 分销(赏)

Java程序员认证模拟题及详细分析.doc

上传人:a199****6536 文档编号:3635943 上传时间:2024-07-11 格式:DOC 页数:138 大小:174KB
下载 相关 举报
Java程序员认证模拟题及详细分析.doc_第1页
第1页 / 共138页
Java程序员认证模拟题及详细分析.doc_第2页
第2页 / 共138页
Java程序员认证模拟题及详细分析.doc_第3页
第3页 / 共138页
Java程序员认证模拟题及详细分析.doc_第4页
第4页 / 共138页
Java程序员认证模拟题及详细分析.doc_第5页
第5页 / 共138页
点击查看更多>>
资源描述

1、Java程序员认证模拟题及详细分析资料仅供参考一.说明:(真实考试)1.考试形式:网络计算机2.考题形式:多选,单选,简答3.题量:604.考试时间:120分钟二.模拟题1.Which statement about the garbage collection mechanism are true?A. Garbage collection require additional programe code in cases where multiple threads are running.B. The programmer can indicate that a reference th

2、rough a local variable is no longer of interest.C. The programmer has a mechanism that explicity and immediately frees the memory used by Java objects.D. The garbage collection mechanism can free the memory used by Java Object at explection time.E. The garbage collection system never reclaims memory

3、 from objects while are still accessible to running user threads.2. Give the following method:1) public void method( )2) String a,b;3) a=new String(“hello world”);4) b=new String(“game over”);5) System.out.println(a+b+”ok”);6) a=null;7) a=b;8) System.out.println(a);9) In the absence of compiler opti

4、mization, which is the earliest point the object a refered is definitely elibile to be garbage collection.A. before line 3B.before line 5C. before line 6D.before line 7E. Before line 93. In the class java.awt.AWTEvent,which is the parent class upon which jdk1.1 awt events are based there is a method

5、 called getID which phrase accurately describes the return value of this method?A. It is a reference to the object directly affected by the cause of the event.B. It is an indication of the nature of the cause of the event.C. It is an indication of the position of the mouse when it caused the event.D

6、. In the case of a mouse click, it is an indication of the text under the mouse at the time of the event.E. It tells the state of certain keys on the keybord at the time of the event.F. It is an indication of the time at which the event occurred.4. Which statement about listener is true?A. Most comp

7、onent allow multiple listeners to be added.B. If multiple listener be add to a single component, the event only affected one listener.C. Component don?t allow multiple listeners to be add.D. The listener mechanism allows you to call an addXxxxListener method as many times as is needed, specifying as

8、 many different listeners as your design require.5.Give the following code:public class Examplepublic static void main(String args )int l=0;doSystem.out.println(“Doing it for l is:”+l);while(-l0)System.out.println(“Finish”);Which well be output:A. Doing it for l is 3B. Doing it for l is 1C. Doing it

9、 for l is 2D. Doing it for l is 0E. Doing it for l is ?C1F. Finish见1-5题答案答案及详细分析:1。B、EJAVA的垃圾回收机制是经过一个后台系统级线程对内存分配情况进行跟踪实现的,对程序员来说是透明的,程序员没有任何方式使无用内存显示的、立即的被释放。而且它是在程序运行期间发生的。答案B告诉我们程序员能够使一个本地变量失去任何意义,例如给本地变量赋值为“null”;答案E告诉我们在程序运行期间不可能完全释放内存。2。D第6行将null赋值给a以后,a以前保存的引用所指向的内存空间就失去了作用,它可能被释放。因此对象a可能最早被

10、垃圾回收是在第7行以前,故选择D选项。3。B请查阅JAVA类库。getID方法的返回值是“event type”。在认证考试中,总会有类似的书本以外的知识,这只能靠多实践来增长知识了。4。A、D控件能够同时使用多个“addXxxxListener”方法加入多个监听器。而且当多个监听器加入到同一控件中时,事件能够响应多个监听器,响应是没有固定顺序的。5。D、F本题主要考察考生对流程控制的掌握情况。这是当型循环,条件为真执行,条件为假则退出。循环体至少执行一次,故会输出D。循环体以外的语句总会被执行,故输出F。6. Give the code fragment:1) switch(x)2) cas

11、e 1:System.out.println(“Test 1”);break;3) case 2:4) case 3:System.out.println(“Test 2”);break;5) default:System.out.println(“end”);6) which value of x would cause “Test 2” to the output:A. 1B. 2C. 3D. default7. Give incompleted method:1)2) if(unsafe()/do something3) else if(safe()/do the other4) The

12、 method unsafe() well throe an IOException, which completes the method of declaration when added at line one?A. public IOException methodName()B. public void methodName()C. public void methodName() throw IOExceptionD. public void methodName() throws IOExceptionE. public void methodName() throws Exce

13、ption8. Give the code fragment:if(x4)System.out.println(“Test 1”);else if (x9)System.out.println(“Test 2”);else System.out.println(“Test 3”);Which range of value x would produce of output “Test 2”?A. x4C. x9D. None9. Give the following method:public void example()tryunsafe();System.out.println(“Test

14、1”);catch(SafeException e)System.out.println(“Test 2”);finallySystem.out.println(“Test 3”);System.out.println(“Test 4”);Which will display if method unsafe () run normally?A. Test 1B. Test 2C. Test 3D. Test 410. Which method you define as the starting point of new thread in a class from which new th

15、e thread can be excution?A. public void start()B. public void run()C. public void int()D. public static void main(String args)E. public void runnable()6-10答案:6。B.C在开关语句中,标号总是不被当做语句的一部分,标号的作用就是做为条件判断而已,一旦匹配成功,就执行其后的语句,一直遭遇break语句为止。(包括default语句在内)7。D、FIOException异常类是Exception的子类。根据多态性的定义,IOException对

16、象也能够被认为是Exception类型。还要注意在方法声明中抛出异常应用关键字“throws”。8。D只有两种情况:大于4时输出“Test1”,小于等于4时输出“Test3”。9。A、C、D在正常情况下,打印Test1、Test3、Test4;在产生可捕获异常时打印Test2、Test3、Test4;在产生不可捕获异常时,打印Test3,然后终止程序。注意finally后面的语句总是被执行。10。B线程的执行是从方法“run( )”开始的,该方法是由系统调用的。程序员手工调用方法start(),使线程变为可运行状态。11.Given the following class definition

17、:class Aprotected int i;A(int i)this.i=i;which of the following would be a valid inner class for this class?Select all valid answers:A. class BB. class B extends AC. class B extends AB()System.out.println(“i=”+i);D. class Bclass AE. class A12. Which modifier should be applied to a method for the loc

18、k of object this to be obtained prior to excution any of the method body?A. synchronizedB. abstractC. finalD. staticE. public13. The following code is entire contents of a file called Example.java,causes precisely one error during compilation:1) class SubClass extends BaseClass2) 3) class BaseClass(

19、)4) String str;5) public BaseClass()6) System.out.println(“ok”);7) public BaseClass(String s)8) str=s;9) public class Example10) public void method()11) SubClass s=new SubClass(“hello”);12) BaseClass b=new BaseClass(“world”);13) 14) Which line would be cause the error?A. 9 B. 10 C. 11 D.1214. Which

20、statement is correctly declare a variable a which is suitable for refering to an array of 50 string empty object?A. String aB. String aC. char aD. String a50F. Object a5015. Give the following java source fragement:/point xpublic class Interesting/do somethingWhich statement is correctly Java syntax

21、 at point x?A. import java.awt.*;B.package mypackageC. static int PI=3.14D. public class MyClass/do other thing E. class MyClass/do something11-15答案:11。A此题考查内部类及关键字“super”的用法。内部类不能与外部类同名。另外,当B继承A时,A中的构造函数是带参数的,B中缺省构造函数的函数体为空;而JAVA编译器会为空构造函数体自动添加语句“super();”调用父类构造函数,更进一步是调用父类的参数为空的构造函数。而父类中没有参数为空的构造函

22、数。12。A此关键字能够在两个线程同时试图访问某一数据时避免数据毁损。13。C当一个类中未显式定义构造函数时,缺省的构造函数是以类名为函数名,参数为空,函数体为空。虽然父类中的某一构造函数有字符串参数s,可是子类继承父类时并不继承构造函数,因此它只能使用缺省构造函数。故在第11行出错。14。A、B注意,题中问的是如何正确声明一个一维数组,并非实例化或者初始化数组15。A、EX处能够是一个输入,包的定义,类的定义。由于常量或变量的声明只能在类中或方法中,故不能选择C;由于在一个文件中只能有一个public类,故不能选择D。16. Give this class outline:class Exa

23、mpleprivate int x;/rest of class bodyAssuming that x invoked by the code java Example, which statement can made x be directly accessible in main() method of Example.java?A. Change private int x to public int xB. change private int x to static int xC. Change private int x to protected int xD. change

24、private int x to final int x17. the piece of preliminary analsis work describes a class that will be used frequently in many unrelated parts of a project“The polygon object is a drawable, A polygon has vertex information stored in a vector, a color, length and width.”Which Data type would be used?A.

25、 VectorB. intC. StringD. ColorE. Date18. A class design requires that a member variable should be accessible only by same package, which modifer word should be used?A. protectedB. publicC. no modiferD. private19.Which declares for native method in a java class corrected?A. public native void method(

26、)B. public native void method();C. public native method();D. public void method()native;E. public void native method();20. Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?16-20答安:16。B静态方法除了自己的参数

27、外只能直接访问静态成员。访问非静态成员,必须先实例化本类的一个实例,再用实例名点取。17。A、B、Dpolygon的顶点信息存放在Vector类型的对象内部,color定义为Color,length和width定义为int。注意,这是考试中常见的题型。18。C此题考点是高级访问控制。请考生查阅高级访问控制说明表格。19。Bnative关键字指明是对本地方法的调用,在JAVA中是只能访问但不能写的方法,它的位置在访问权限修饰语的后面及返回值的前面。20。final定义常量的方法是在变量定义前加final关键字。21. Which is the main() method return of a

28、application?A. StringB. byteC. charD. void22. Which is corrected argument of main() method of application?A. String argsB. String arC. Char argsD. StringBuffer arg23. “The Employee object is a person, An Employee has appointment store in a vector, a hire date and a number of dependent”short answer:

29、use shortest statement declare a class of Employee.24. Give the following class defination inseparate source files:public class Examplepublic Example()/do somethingprotected Example(int i)/do somethingprotected void method()/do somethingpublic class Hello extends Example/member method and member var

30、iableWhich methods are corrected added to the class Hello?A. public void Example()B. public void method()C. protected void method()D. private void method()25. Float s=new Float(0.9F);Float t=new Float(0.9F);Double u=new Double(0.9);Which expression?s result is true?A. s=tB. s.equals(t)C. s=uD. t.equ

31、als(u)21-15答案:21。Dmain()方法没有返回值,因此必须用void修饰。main()方法的返回值不能任意修改。22。Bmain()方法的参数是字符串数组,参数名能够任意定义。23。public class Employee extends Person这也是真实考试中常见的一种题型。要注意题目叙述中“is a”表示 “extends”的含义。24。A、B、C考察的知识点是方法覆盖,其中要注意的是方法覆盖时,子类方法的访问权限不能小于父类方法的访问权限。另外,选项A并不是父类构造函数,它是子类中的新方法。25。A、B考察“=”及方法“equals()”的用法。注意以下几点区别:1

32、) 引用类型比较引用;基本类型比较值。2) equals()方法只能比较引用类型,“=”可比较引用及基本类型。3) 当用equals()方法进行比较时,对类File、String、Date及封装类(Wrapper Class)来说,是比较类型及内容。4) 用“=”进行比较时,符号两边的数据类型必须一致(可相互转换的基本类型除外),否则编译出错。26. Give following class:class AClassprivate long val;public AClass(long v)val=v;public static void main(String args)AClass x=n

33、ew AClass(10L);AClass y=new AClass(10L);AClass z=y;long a=10L;int b=10;Which expression result is true?A. a=b;B. a=x;C. y=z;D. x=y;E. a=10.0;27. A socket object has been created and connected to a standard internet service on a remote network server. Which construction give the most suitable means f

34、or reading ASCII data online at a time from the socket?A. InputStream in=s.getInputStream();B. DataInputStream in=new DataInputstream(s.getInputStream();C. ByteArrayInputStream in=new ByteArrayInputStream(s.getInputStream();D. BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStre

35、am();E. BufferedReader in=new BufferedReader(new InputStreamReader(s.getInputStream(),”8859-1”);28. String s=”Example String”;Which operation is legal?A. s=3;B. int i=s.length();C. s3=”x”;D. String short_s=s.trim();E. String t=”root”+s;29. What happens when you try to compile and run the following p

36、rogram?class MysteryString s;public static void main(String args)Mystery m=new Mystery();m.go();void Mystery()s=”constructor”;void go()System.out.println(s);A. this code will not compileB. this code compliles but throws an exception at runtimeC. this code runs but nothing appears in the standard out

37、putD. this code runs and “constructor” in the standard outputE. this code runs and writes ”null” in the standard output30. What use to position a Button in a Frame ,only width of Button is affected by the Frame size, which Layout Button well be set ?A. FlowLayout;B. GridLayout;C. North of BorderLayo

38、utD. South of BorderLayoutE. East or West of BorderLayout31. What use to position a Button in a Frame, size of Button is not affected by the Frame size, which Layout Button will be set?A. FlowLayout;B. GridLayout;C. North of BorderLayoutD. South of BorderLayoutE. East or West of BorderLayout32. An A

39、WT GUI under exposure condition, which one or more method well be invoke when it redraw?A. paint();B. update();C. repaint();D. drawing();33. Select valid identifier of Java:A. userNameB. %passwdC. 3d_gameD. $charge E. this34. Which are Java keyword?A. gotoB. nullC. FALSED. nativeE. const35. Run a co

40、rrected class: java ?Ccs AClass a b cWhich statement is true?A. args0=”-cs”;B. args1=”a b c”;C. args0=”java”;D. args0=”a”; E. args1=?b?36. Give the following java class:public class Examplestatic int x=new int15;public static void main(String args)System.out.println(x5);Which statement is corrected?

41、A. When compile, some error will occur.B. When run, some error will occur.C. Output is zero.D. Output is null.37. Give the following java class:public class Examplepublic static void main(String args)static int x = new int15;System.out.println(x5);Which statement is corrected?A. When compile, some error will occur.B. When run, some error will occur.C. Output is zero.D. Output is null.38. Short answer:The decimal value of i is 12, the octal i value is:39. Short answer:The decimal value of i is 7, the hexadecimal i value is:40. Which is the range of char?A.

展开阅读全文
部分上传会员的收益排行 01、路***(¥15400+),02、曲****(¥15300+),
03、wei****016(¥13200+),04、大***流(¥12600+),
05、Fis****915(¥4200+),06、h****i(¥4100+),
07、Q**(¥3400+),08、自******点(¥2400+),
09、h*****x(¥1400+),10、c****e(¥1100+),
11、be*****ha(¥800+),12、13********8(¥800+)。
相似文档                                   自信AI助手自信AI助手
百度文库年卡

猜你喜欢                                   自信AI导航自信AI导航
搜索标签

当前位置:首页 > 通信科技 > 开发语言

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服