【计算机类职业资格】计算机Java认证-理解方法和变量的作用域、数组编程及答案解析.doc
《【计算机类职业资格】计算机Java认证-理解方法和变量的作用域、数组编程及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】计算机Java认证-理解方法和变量的作用域、数组编程及答案解析.doc(25页珍藏版)》请在麦多课文档分享上搜索。
1、计算机 Java认证-理解方法和变量的作用域、数组编程及答案解析(总分:100.00,做题时间:90 分钟)一、B不定项选择题/B(总题数:30,分数:100.00)1.A method needs to be created that accepts an array of floats as an argument and does not return any variables. The method should be called setPoints. Which of the following method declarations is correct? A. setPoin
2、ts(float points) . B. void setPoints(float points) . C. void setPoints(float points) . D. float setPoints(float points) .(分数:3.00)A.B.C.D.2.When the void keyword is used, which of the following statements are true? (Choose all that apply.) A. A return statement with a value following it must be used
3、. B. A return statement with a value following it can optionally be used. C. A return statement with a value following it should never be used. D. A return statement by itself must be used. E. A return statement by itself can optionally be used. F. A return statement by itself should never be used.
4、G. A return statement must be omitted. H. A return statement can optionally be omitted. I. A return statement should never be omitted.(分数:3.00)A.B.C.D.E.F.G.H.I.3.Given the SampleClass, what is the output of this code segment?SampleClass s = new SampleClass();s.sampleMethod(4.4, 4);public class Samp
5、leClass public void sampleMethod(int a, double b) System.out.println(“Method 1“);public void sampleMethod(double b, int a) System.out.println(“Method 2“); A. Method 1 B. Method 2 C. Method 1 Method 2 D. Method 2 Method 1 E. Compiler error(分数:3.00)A.B.C.D.E.4.Given the class FloatNumber and method ad
6、dHalf, what is the output if the following code segment is executed?public class FloatNumber float number;public FloatNumber(float number this.number = number;floatgetNumber( retum number;void setNumber(float number) this.number = number;void addHalf(FloatNumber value) value.setNumber(value.getNumbe
7、r()+(value.getNumber()/2f);/* CODE SEGMENT */FloatNumber value = new FloatNumber(1f);addHalf(value);System.out.println(“value =“+value.getNumber(); A. value = 1 B. value = 1.5 C. value = 2 D. value = 0(分数:3.00)A.B.C.D.5.Objects are passed by _. A. Value B. Sum C. Reference D. Pointer(分数:3.00)A.B.C.D
8、.6.Primitives are passed by _. A. Value B. Sum C. Reference D. Pointer(分数:3.00)A.B.C.D.7.You need to create a class to store information about books contained in a library. What variable scope is best suited for the variable that will store the title of a book? A. Local variable B. Static variable C
9、. Global variable D. Method parameter E. Instance variable(分数:3.00)A.B.C.D.E.8.Given the SampleClass, when the following code segment is executed, what is the value of the instance variable size?SampleClass sampleClass = new SampleClass(5);public class SampleClass private int size;public SampleClass
10、(int size) size = size; A. 0 B. 1 C. 5 D. Compiler error E. Runtime error(分数:3.00)A.B.C.D.E.9.Given the SampleClass, what is the output of this code segment?SampleClass sampleClass = new SampleClass();public class SampleClass private int size;private int priority;public SampleClass() super();System.
11、out.println(“Using default values“);public SampleClass(int size) this.size = size;System.out.println(“Setting size“);public SampleClass(int priority) this.priority = priority;System.out.println(“Setting priority“); A. Using default values B. Setting size C. Setting priority D. Compiler error(分数:3.00
12、)A.B.C.D.10.What constructor is equivalent to the one listed here?public SampleConstructor( System.out.println(“SampleConstructor“); A. public SampleConstructor() this(); System.out.println(“Sample Constructor“); B. public SampleConstructor() super(); System.out.println(“Sample Constructor“); C. pub
13、lic SampleConstructor() this.SampleConstructor(); System.out.println(“Sample Constructor“); D. public SampleConstructor() super.SampleConstructor(); System.out.println(“Sample Constructor“); E. None of the above(分数:3.00)A.B.C.D.E.11.Given the SampleClass, what is the output of this code segment?Samp
14、leClass sampleClass = new SampleClass();public class SampleClass private int size;public SampleClass() this(1);System.out.println(“Using default values“);public SampleClass(int size) this.size = size;System.out.println(“Setting size“); A. Using default values B. Setting size C. Using default values
15、Setting size D. Setting size Using default values E. Compiler error(分数:3.00)A.B.C.D.E.12.What is the effect of the following line of code?super() A. The method that is overridden by the current method is called. B. The parent classs constructor is called. C. The current classs constructor is called.
16、 D. The child classs constructor is called E. The current method is recursively called.(分数:3.00)A.B.C.D.E.13.Given the SampleClass, what is the output of this code segment?SampleClass s = new SampleClass();SampleClass.sampleMethodOne();public class SampleClass public static void sampleMethodOne() sa
17、mpleMethodTwo();System.out.println(“sampleMethodOne“);public void sampleMethodTwo() System.out.println(“sampleMethodTwo“); A. sampleMethodOne B. sampleMethodTwo C. sampleMethodOne sampleMethodTwo D. sampleMethodTwo sampleMethodOne E. Compiler error(分数:3.00)A.B.C.D.E.14.Given the SampleClass, what is
18、 the value of currentCount for the instance of object x after the code segment had be executed?SampleClass x = new SampleClass();SampleClass y = new SampleClass();x.increaseCount();public class SampleClass private static int currentCount=();public SampleClass() currentCount+;public void increaseCoun
19、t() currentCount+; A. 0 B. 1 C. 2 D. 3 E. Compiler error F. Runtime error(分数:3.00)A.B.C.D.E.F.15.Static methods have access to which of the following? (Choose all that apply.) A. Static variables B. Instance variables C. Standard methods D. Static Methods E. None of the above(分数:3.00)A.B.C.D.E.16.Wh
20、at lines will compile without errors? (Choose all that apply.) A. Object obj = new Object(); B. Object obj = new Object(); C. Object obj = new Object(); D. Object obj = new Object; E. Object obj = new Object3(); F. Object obj = new Object7; G. Object obj = new Object; H. Object obj = new Object3();
21、I. Object obj = new Object7; J. Object8 obj = new Object; K. Object3 obj = new Object3(); L. Object7 obj = new Object7; M. Object obj = new new Object(), new Object(); N. Object obj = new Object(), new Object(); O. Object obj = new Object1, new Object2;(分数:3.00)A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.17.What
22、is the output of the following code segment?String numbers = “One“, “Two“, “Three“;System.out.println(numbers3+“ “+numbers2+“ “+numbers1); A. One Two Three B. Three Two One C. A compile time error will be generated. D. A runtime exception will be thrown.(分数:3.00)A.B.C.D.18.What is the output of the
23、following code segment?String numbers = “One“ “Two“, “Three“;for(String s : numbers)System.out.print(s+“ “); A. One Two Three B. Three Two One C. A compile time error will be generated. D. A runtime exception will be thrown.(分数:3.00)A.B.C.D.19.What is the output of the following code segment?int tes
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 JAVA 认证 理解 方法 变量 作用 数组 编程 答案 解析 DOC
