




已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
SCJP考试题310-025原题及解答 1. Which statement are characteristics of the and operators. A. performs a shift B. performs a rotate C. performs a signed and performs an unsigned shift D. performs an unsigned and performs a signed shift E. should be used on integrals and should be used on floating point types C. 2. Given the following declaration String s = Example; Which are legal code? A. s = 3; B. s3 = x; C. int i = s.length(); D. String t = For + s; E. s = s + 10; CDE. 3. Given the following declaration String s = hello; Which are legal code? A. s = 2; B. char c = s3; C. s += there; D. int i = s.length(); E. s = s + 3; CDE. 4. Which statements are true about listeners? A. The return value from a listener is of boolean type. B. Most components allow multiple listeners to be added. C. A copy of the original event is passed into a listener method. D. If multiple listeners are added to a single component, they all must all be friends to each other. E. If the multiple listeners are added to a single component, the order in which listeners are called is guaranteed. BC. 5. What might cause the current thread to stop executing. A. An InterruptedException is thrown. B. The thread executes a wait() call. C. The thread constructs a new Thread. D. A thread of higher priority becomes ready. E. The thread executes a waitforID() call on a MediaTracker. ABDE.6. Given the following incomplete method. 1. public void method() 2. 3. if (someTestFails() 4. 5. 6. 7. You want to make this method throw an IOException if, and only if, the method someTestFails() returns a value of true. Which changes achieve this? A. Add at line 2: IOException e; B. Add at line 4: throw e; C. Add at line 4: throw new IOException(); D. Add at line 6: throw new IOException(); E. Modify the method declaration to indicate that an object of type Exception might be thrown. CE. 7. Which modifier should be applied to a method for the lock of the object this to be obtained prior to executing any of the method body? A. final B. static C. abstract D. protected E. synchronized E. 8. Which are keywords in Java? A. NULL B. true C. sizeof D. implements E. instanceof DE. 9. Consider the following code: Integer s = new Integer(9); Integer t = new Integer(9); Long u = new Long(9); Which test would return true? A. (s=u) B. (s=t) C. (s.equals(t) D. (s.equals(9) E. (s.equals(new Integer(9) CE.10. Why would a responsible Java programmer want to use a nested class? A. To keep the code for a very specialized class in close association with the class it works with. B. To support a new user interface that generates custom events. C. To impress the boss with his/her knowledge of Java by using nested classes all over the place. AB. 11. You have the following code. Which numbers will cause Test2 to be printed? switch(x) case 1: System.out.println(Test1); case 2: case 3: System.out.println(Test2); break; System.out.println(Test3); A. 0 B. 1 C. 2 D. 3 E. 4 BCD. 12. Which statement declares a variable a which is suitable for referring to an array of 50 string objects? A. char a; B. String a; C. String a; D. Object a50; E. String a50; F. Object a; BCF. 13. What should you use to position a Button within an application frame so that the width of the Button is affected by the Frame size but the height is not affected. A. FlowLayout B. GridLayout C. Center area of a BorderLayout D. East or West of a BorderLayout E. North or South of a BorderLayout E. 14. What might cause the current thread to stop executing? A. An InterruptedException is thrown B. The thread executes a sleep() call C. The thread constructs a new Thread D. A thread of higher priority becomes ready (runnable) E. The thread executes a read() call on an InputStream ABDE. Non-runnable states: * Suspended: caused by suspend(), waits for resume() * Sleeping: caused by sleep(), waits for timeout * Blocked: caused by various I/O calls or by failing to get a monitors lock, waits for I/O or for the monitors lock * Waiting: caused by wait(), waits for notify() or notifyAll() * Dead: Caused by stop() or returning from run(), no way out15. Consider the following code: String s = null; Which code fragments cause an object of type NullPointerException to be thrown? A. if(s!=null) & (s.length()0) B. if(s!=null) &(s.length()0) C. if(s=null) | (s.length()=0) D. if(s=null) | (s.length()=0) AC. 16. Given the following method body: if (sometest() unsafe(); else safe(); The method unsafe might throw an IOException (which is not a subclass of RunTimeException). Which correctly completes the method of declaration when added at line one? A. public void methodName() throws Exception B. public void methodname() C. public void methodName() throw IOException D. public void methodName() throws IOException E. public IOException methodName() AD. 17. What would be the result of attempting to compile and run the following piece of code? public class Test static int x; public static void main(String args) System.out.println(Value is + x); A. The output Value is 0 is printed. B. An object of type NullPointerException is thrown. C. An illegal array declaration syntax compiler error occurs. D. A possible reference before assignment compiler error occurs. E. An object of type ArrayIndexOutOfBoundsException is thrown. A. 18. What would be the result of attempting to compile and run the following piece of code? public class Test public int x; public static void main(String args) System.out.println(Value is + x); A. The output Value is 0 is printed. B. Non-static variable x cannot be referenced from a static context. C. An illegal array declaration syntax c
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
评论
0/150
提交评论