![SCJP模拟题 AND Answer [1].doc_第1页](http://file.renrendoc.com/FileRoot1/2020-1/11/8796471a-9c56-4b20-afef-44815400ecbe/8796471a-9c56-4b20-afef-44815400ecbe1.gif)
![SCJP模拟题 AND Answer [1].doc_第2页](http://file.renrendoc.com/FileRoot1/2020-1/11/8796471a-9c56-4b20-afef-44815400ecbe/8796471a-9c56-4b20-afef-44815400ecbe2.gif)
![SCJP模拟题 AND Answer [1].doc_第3页](http://file.renrendoc.com/FileRoot1/2020-1/11/8796471a-9c56-4b20-afef-44815400ecbe/8796471a-9c56-4b20-afef-44815400ecbe3.gif)
![SCJP模拟题 AND Answer [1].doc_第4页](http://file.renrendoc.com/FileRoot1/2020-1/11/8796471a-9c56-4b20-afef-44815400ecbe/8796471a-9c56-4b20-afef-44815400ecbe4.gif)
![SCJP模拟题 AND Answer [1].doc_第5页](http://file.renrendoc.com/FileRoot1/2020-1/11/8796471a-9c56-4b20-afef-44815400ecbe/8796471a-9c56-4b20-afef-44815400ecbe5.gif)
已阅读5页,还剩22页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Question 1: Which of the following class definitions defines a legal abstract class? Select all right answers. a) class Animal abstract void growl(); b) abstract Animal abstract void growl(); c) class abstract Animal abstract void growl(); d) abstract class Animal abstract void growl(); e) abstract class Animal abstract void growl() System.out.println(growl); Question 2: For an object to be a target for a Thread, that object must be of type: Fill in the blank. Question 3: What is the proper way of defining a class named Key so that it cannot be subclassed? a) class Key b) abstract final class Key c) native class Key d) class Key final; e) final class Key Question 4: What modes are legal for creating a new RandomAccessFile object? Select all valid answers. a) w b) r c) x” d) rw e) xrw Question 5: Given the following code: class Tester public static void main(String args) CellPhone cell = new CellPhone(); cell.emergency(); class Phone final void dial911() / code to dial 911 here . . . class CellPhone extends Phone void emergency() dial911(); What will happen when you try to compile and run the Tester class? a) The code will not compile because Phone is not also declared as final. b) The code will not compile because you cannot invoke a final method from a subclass. c) The code will compile and run fine. d) The code will compile but will throw a NoSuchMethodException when Tester is run. e) Phone and CellPhone are fine, but Tester will not compile because it cannot create an instance of a class that derives from a class defining a final method. Question 6: Which assignments are legal? Select all valid answers. a) long test = 012; b) float f = -412; c) int other = (int)true; d) double d = 0x12345678; e) short s = 10; Question 7: Given this class definitions: abstract class Transaction implements Runnable class Deposit extends Transaction protected void process() addAmount(); void undo(int i) System.out.println(Undo); What will happen if we attempted to compile the code? Select the one right answer. a) This code will not compile because the parameter i is not used in undo(). b) This code will not compile because there is no main() method. c) This code will not compile because Deposit must be an abstract class. d) This code will not compile because Deposit is not declared public. e) Everything will compile fine. Question 8: Which exception might wait() throw? Fill in the blank. Question 9: Which of the following are not Java keywords: Select all valid answers. a) superclass b) goto c) open d) close e) integer f) goto, import g) they are all valid keywords Question 10: Which of the following represents an octal number? Select all that apply. a) 0x12 b) 32O c) 032 d) (octal)2 e) 1 Question 11: What will appear in the standard output when you run the Tester class? class Tester int var; Tester(double var) this.var = (int)var; Tester(int var) this(hello); Tester(String s) this(); System.out.println(s); Tester() System.out.println(good-bye); public static void main(String args) Tester t = new Tester(5); a) nothing b) hello c) 5 d) hello followed by good-bye e) good-bye followed by hello Question 12: Write a line of code to use the String抯 substring() method to obtain the substring lip from a String instance named s that is set to tulip. Fill in the blank. Question 13: There are a number of labels in the source code below. These are labeled a through j. Which label identifies the earliest point where, after that line has executed, the object referred to by the variable first may be garbage collected? class Riddle public static void main(String args) String first, second; String riddle; if (args.length 0) if (argsindex.equals(Hiway) milesPerGallon*= 2; System.out.println(mpg: + milesPerGallon); Select the one right answer. a)The code compiles and displays mpg: 50 if the command-line argument is Hiway. If the command-line argument is not Hiway, the code displays mpg: 25. b) The code compiles and displays mpg: 50 if the command-line argument is Hiway. If the command-line argument is not Hiway, the code throws an ArrayIndexOutOfBoundsException. c) The code does not compile because the automatic variable named index has not been initialized. d) The code does not compile because milesPerGallon has not been initialized. e) The code does not compile because the no-args constructor is not written correctly. Question 16: What will happen when you compile and run this program: class Array public static void main(String args) int length = 100; int d = new intlength; for (int index = 0; index length; index+) System.out.println(dindex); Select the one right answer. a) The code will not compile because the int array is not declared correctly. b) The code will compile but will throw an IndexArrayOutOfBoundsException when it runs and nothing will appear in the standard output. c) The code will display the numbers 0 through 99 in the standard output, and then throw an IndexOutOfBoundsException. d) The code will compile but the println() method will throw a NoSuchMethodException. e) This code will work fine and display 100 zeroes in the standard output. Question 17: What is the result of attempting to compile and run the following class? class Ar public static void main(String args) int seeds = new int3; for (int i = 0; i d) & e) none of these Question 23: How can you change the break statement below so that it breaks out of both the inner and middle loops and continues with the next iteration of the outer loop? outer: for (int x = 0; x 3; x+) middle: for (int y = 0; y 3; y+) inner: for (int z = 0; z 3) d) float myFloat = 40.0; e) boolean b = (boolean)99; Question 40: Which label name(s) are illegal? Select all valid answers. a) here: b) _there: c) this: d) that: e) 2to1odds: Question 41: Given this code: import java.io.*; class Write public static void main(String args) throws Exception File file = new File(temp.test); FileOutputStream stream = new FileOutputStream(file); / write integers here. . . How can you replace the comment at the end of main() with code that will write the integers 0 through 9? Select the one right answer. a) DataOutputStream filter = new DataOutputStream(stream); for (int i = 0; i 10; i+) filter.writeInt(i); b) for (int i = 0; i 10; i+) file.writeInt(i); c) for (int i = 0; i 10; i+) stream.writeInt(i); d) DataOutputStream filter = new DataOutputStream(stream); for (int i = 0; i 10; i+) filter.write(i); e) for (int i = 0; i 10; i+) stream.write(i); Question 42: What keyword, when used in front of a method, must also appear in front of the class? Fill in the blank. Question 43: What letters get written to the standard output with the following code? class Unchecked public static void main(String args) try method(); catch (Exception e) static void method() try wrench(); System.out.println(a); catch (ArithmeticException e) System.out.println(b); finally System.out.println(c); System.out.println(d); static void wrench() throw new NullPointerException(); Select all valid answers. a) a b) b c) c d) d e) none of these Question 44: What happens if the file Ran.test does not yet exist and you attempt to compile and run the following code? import java.io.*; class Ran public static void main(String args) throws IOException RandomAccessFile out = new RandomAccessFile(Ran.test, rw); out.writeBytes(Ninotchka); Select the one right answer. a) The code does not compile because RandomAccessFile is not created correctly. b) The code does not compile because RandomAccessFile does not implement the writeBytes() method. c) The code compiles and runs but throws an IOException because Ran.test does not yet exist. d) The code compiles and runs but nothing appears in the file Ran.test that it creates. e) The code compiles and runs and Ninotchka appears in the file Ran.test that it creates. Question 45: If you run the following code on a on a PC from the directory c:source: import java.io.*; class Path public static void main(String args) throws Exception File file = new File(Ran.test); System.out.println(file.getAbsolutePath(); what do you expect the output to be? Select the one right answer. a) Ran.test b) sourceRan.test c) c:sourceRan.test d) c:source e) null Question 46: If you supply a target object when you create a new Thread, as in: Thread t = new Thread(targetObject); What test of instanceof does targetObject have to pass for this to be legal? Select the one right answer. a) targetObject instanceof Thread b) targetObject instanceof Object c) targetObject instanceof Applet d) targetObject instanceof Runnable e) targetObject instanceof String Question 47: What appears in the standard output when you run the Dots class? class Dots implements Runnable DotThread t; public static void main(String args) Dots d = new Dots(); d.t = new DotThread(); public void init() t.start(); t = new DashThread().start(); class DotThread extends Thread public void run() for (int index = 0; index 100; index+) System.out.print(.); class DashThread extends Thread public void run() for (int index = 0; index 100; index+) System.out.print(-); a) nothing b) 100 dots (.) c) 200 dots (.) d) 100 dashes (-) e) 100 dots (.) and 100 dashes(-) Question 48: When you invoke repaint() for a Component, the AWT package calls which Component method? a) repaint() b) update() c) paint() d) draw() e) show() Question 49: How you can you test whether an object referenced by ref implements an interface named MyInterface? Replace your test here with this test: if (your test here) System.out.println(ref implements MyInterface);
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 惠州消防知识培训班课件地址
- 情绪世界课件
- 情感升华课件
- 销售管理工作方案
- 恶性心律失常的识别课件
- “绿化环境,播种绿色”植树节活动方案
- 老年趣味运动会活动策划方案
- 孤儿学校初中语文随班就读的工作方案
- 护士理论考试题及答案
- 扬州电动车考试试题及答案
- 【《惠东农商银行个人信贷业务发展现状及存在的问题和策略分析》15000字】
- 光伏项目开发培训课件
- 职业年金政策讲解
- 智联猎头企业薪酬调研白皮书-2025年年中盘点
- 基孔肯雅热、登革热等重点虫媒传染病防控技术试题
- 消防设施操作员(监控方向)中级模拟考试题及答案
- 2025年事业单位教师考试公共基础知识试题(含答案)
- 2025年可靠性工程师MTBF计算强化练习
- 2025秋季学期中小学学校学生校服采购工作方案
- 乳房肿块鉴别诊断
- 普速铁路信号维护规则业务管理
评论
0/150
提交评论