Java模拟题new.doc_第1页
Java模拟题new.doc_第2页
Java模拟题new.doc_第3页
Java模拟题new.doc_第4页
Java模拟题new.doc_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Java程序员认证模拟题(only for trainning)一.说明:(真实考试) 1.考试形式:网络计算机 2.考题形式:多选,单选,简答 3.题量:60 4.考试时间: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 through 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 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 optimization, which is the earliest point the object a refered is definitely elibile to be garbage collection.A. before line 3 B.before line 5 C. before line 6 D.before line 7 E. 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 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. 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 component allow multiple listeners to be added.B. If multiple listener be add to a single component, the event only affected one listener.C. Component dont 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 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 for l is 2D. Doing it for l is 0E. Doing it for l is 1F. Finish6. Give the code fragment:1) switch(x)2) case 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 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 Exception8. 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(“Test1”);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 the 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()11.Given the following class definition: 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 lock 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()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. 9B. 10C. 11D.1214. Which 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 at point x?A. import java.awt.*;B.package mypackageC. static int PI=3.14D. public class MyClass/do other thingE. class MyClass/do something16. Give this class outline: class Exampleprivate 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 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. Vector B. int C. 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()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?21. Which is the main() methods return of a application?A. StringB. byteC. charD. void22. Which is corrected argument of main() method of application?A. String argsB. String arC. Char argsD. StringBuffer arg 23. “The Employee object is a person, An Employee has appointment store in a vector, a hire date and a number of dependent”short answer: 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 variableWhich 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 expressions result is true?A. s=tB. s.equals(t)C. s=uD. t.equals(u)26. Give following class: class AClassprivate long val;public AClass(long v)val=v;public static void main(String args)AClass x=new 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 for 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.getInputStream();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 program? 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 outputD. 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 BorderLayoutD. 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 AWT 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. $chargeE. this34. Which are Java keyword?A. gotoB. nullC. FALSED. nativeE. const35. Run a corrected class: java cs AClass a b c Which 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? 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. 2727-1B. 0216-1C. 0216D. 02841. Which is the range of int type?A. -216216-1B.- 231231-1C. -232232-1D. -264264-142. Give the following class: public class ExampleString str=new String(“good”);char ch=a,b,c;public static void main(String args)Example ex=new Example();ex.change(ex.str,ex.ch);System.out.println(ex.str+”and”+ex.ch);public void change(String str,char ch)str=”test ok”;ch0=g;Which is the output: A. good and abcB. good and gbcC. test ok and abcD. test ok and gbc43. Which code fragments would correctly identify the number of arguments passed via command line to a Java application, exclude the name of the class that is being invoke. A. int count = args.length;B. int count = args.length-1;C. int count=0; while(argscount!=null)count+;D. int count=0;while(!(argscount.equals(“”) count+;44. FilterOutputStream is the parent class for BufferedOutputStream, DataOutputStream and PrintStream. Which classes are valid argument for the constructor of a FilterOutputStream?A. InputStreamB. OutputStreamC. FileD. RandomAccessFileE. StreamTokenizer45. Given a TextArea using a proportional pitch font and constructed like this:TextArea t=new TextArea(“12345”,5,5);Which statement is true? A. The displayed width shows exactly five characters one each line unless otherwise constrainedB. The displayed height is five lines unless otherwise constrainedC. The maximum number of characters in a line will be five D. The user will be able to edit the character stringE. The displayed string can use multiple fonts46. Given a List using a proportional pitch font and constructed like this:List l=new List(5,true);Which statement is true?A. The displayed item exactly five lines unless otherwise constrainedB. The displayed item is five lines init, but can displayed more than five Item by scrollC. The maximum number of item in a list will be five.D. The list is multiple mode47. Given this skeleton of a class currently under construction:public class Exampleint x,y,z;public Example (int a, int b) /lots of complex computation x=a; y=b;public Example(int a, int b, int c)/ do everything the same as single argument/ version of constructor/ including assignment x=a, y=b, z=cz=c;What is the most concise way to code the “do everything” part of the constructor taking two arguments?Short answer:48. Which correctly create a two dimensional array of integers?A. int a = new int;B. int a1010 = new int;C. int a = new int1010;D. int a = new int1010;E. int a = new int1010;49. Which are correct class declarations? Assume in each case that the text constitutes the entire contents of a file called Fred.java? A. public class Fredpublic int x = 0;public Fred (int x) this.x=x; B. public class fredpublic int x = 0;public Fred (int x)this.x=x; C. public class Fred extends MyBaseClass, MyOtherBaseClasspublic int x = 0;public Fred(int xval) x=xval; D. protected class Fredprivate int x = 0;private Fred (int xval) x=xval; E. import java.awt.*;public class Fred extends Objectint x;private Fred(int xval) x = xval;50. A class design requires that a particular member variable must be accessible for direct access by any subclasses of this class. but otherwise not by classes which are not members of the same package. What should be done to achieve this?A. The variable should be marked publicB. The variable should be marked privateC. The variable should be marked protectedD. The variable should have no special access modifierE. The variable should be marked private and an accessor method provided 51. Which correctly create an array of five empty Strings?A. String a = new String5;for (int i=0;i5;ai+=”);B. String a =“”,”,”,”,”;C. String a5;D. String 5 a;E. String a = new String5;for (int i = 0 ;i” and “”. Which statement is true?A. 1010 0000 0000 0000 0000 0000 0000 0000 4 give0000 1010 0000 0000 0000 0000 0000 0000B. 1010 0000 0000 0000 0000 0000 0000 0000 4 give1111 1010 0000 0000 0000 0000 0000 0000C. 1010 0000 0000 0000 0000 0000 0000 0000 4 give0000 1010 0000 0000 0000 0000 0000 0000D. 1010 0000 0000 0000 0000 0000 0000 0000 4 give1111 1010 0000 0000 0000 0000 0000 000056. Give following fragment.Outer: for(int i=0; i3; i+)inner:for(int j=0;j1)break outer;System.out.println(j+”and”+i);Which will be output? A. 0 and 0B. 0 and 1C. 0 and 2D. 0 and 3E. 1 and 0F. 1 and 1G. 1 and 2H. 1 and 3I. 2 and 0J. 2 and 1K. 2 and 2L. 2 and 357. Examine the following code which includes an inner class:public final class Test4 implements Aclass Innervoid test()if (Test4.this.flag);sample();private boolean flag=false;public void sample()System.out.println(“Sample”);public Test4()(new Inner().test();public static void main(String args)new Test4();What is the result: A.Print out “Sample”B.Program produces no output but termiantes correctly.C. Program does not terminate.D.The program will not compile58. What is written to the standard output given the following statem

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论