ImageVerifierCode 换一换
格式:DOC , 页数:26 ,大小:145KB ,
资源ID:1336858      下载积分:5000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
如需开发票,请勿充值!快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
注意:如需开发票,请勿充值!
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-1336858.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(【计算机类职业资格】计算机Java认证-Java运算符和字符串编程、使用基本类和变量及答案解析.doc)为本站会员(吴艺期)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

【计算机类职业资格】计算机Java认证-Java运算符和字符串编程、使用基本类和变量及答案解析.doc

1、计算机 Java认证-Java 运算符和字符串编程、使用基本类和变量及答案解析(总分:100.00,做题时间:90 分钟)一、B不定项选择题/B(总题数:34,分数:100.00)1.Given:public class ArithmeticResultsOutput public static void main(String args) int i = 0;int j = 0;if(i+ = +j)System.out.println(“True: i=“+i+“j=“+j); else System.out.println(“False: i=“+i+“j=“+j);What will

2、be printed to standard out? A. True: i=0, j=1 B. True: i=1, j=1 C. False: i=0, j=1 D. False: i=1, j=1(分数:3.00)A.B.C.D.2.Which set of operators represents the complete set of valid Java assignment operators? A. %=, A. 23 B. 3 C. 1 D. 0(分数:3.00)A.B.C.D.4.Given:public class BooleanResultsOutput public

3、static void main(String args) boolean booleanValue1 = true;boolean booleanValue2 = false;System.out.print(!(booleanValue1 System.out.print(!(booleanValue1 | !booleanValue2)+“ “);System.out.print(!(booleanValue1 !booleanValue2);What will be printed, considering the usage of the logical Boolean operat

4、ors? A. false, false, true B. false, true, true C. true, false, true D. true, true, true(分数:3.00)A.B.C.D.5.Given:public class ArithmeticResultsOutput public static void main(String args inti1=100; intj1= 200;if(i1=99) else System.out.print(“Value2: “+(i1+j1+“ “);inti2=100; intj2=200;if(i2=99) else S

5、ystem.out.print(“Value2: “+(i2+j2+“ “);inti3=100; intj3=200;if(i3=100) | (-j3=200) System.out.print(“Value1: “+(i3+j3+“ “); else System.out.print(“Value2: “+(i3+j3+“ “);inti4=100; intj4=200;if(i4=100) | (-j4=200) System.out.print(“Value1: “+(i4+j4+“ “); else System.out.print(“Value2: “+(i4+j4+“ “);W

6、hat will be printed to standard out? A. Value2: 300 Value2: 300 Value1: 300 Value1: 300 B. Value2: 299 Value2: 300 Value1: 299 Value1: 300 C. Value1: 299 Value1: 300 Value2: 299 Value2: 300 D. Value1: 300 Value1: 299 Value2: 300 Value2: 299(分数:3.00)A.B.C.D.6.Given the following code segment:public v

7、oid validatePrime() long p = 17496; /prime number candidateDouble primeSquareRoot = Math.sqrt(p);boolean isPrime = true;for(long j = 2; j= primeSquareRoot.longValue(); j+) if(p % j = = 0) / Print divisorsSystem.out.println(j+“X“+p/j);isPrime = false;System.out.println(“Prime number: “+isPrime);Which

8、 of the following is true? Hint: 17496 is not a prime number. A. The code will not compile due to s syntactical error somewhere in the code. B. The code will not compile since the expression (p % j = 0) should be written as (p % j) = 0). C. Divisors will be printed to standard out (for example, 2x84

9、78, and so on), along with Prime number: false as the final output. D. Divisors will be printed to standard out (for example, 2x8478, and so on), along with “Prime number: 0“ as the final output.(分数:3.00)A.B.C.D.7.Given:public class EqualityTests public static void main (String args)Integer value1 =

10、 new Integer(“312“);Integer value2 = new Integer (“312“);Object object1 = new Object();Object object2 = new Object();Object object3 = value1;Which expressions evaluate to true? A. value1.equals (value2) B. value1.equals (object1) C. value1.equals (object3) D. object1.equals (object2)(分数:3.00)A.B.C.D

11、.8.Given:System.out.print(true | false System.out.println(false What will be printed to standard out? A. true, true B. true, false C. false, true D. false, false E. Compilation error(分数:3.00)A.B.C.D.E.9.Given:System.out.print(3+3+“3“);System.out.print(“and“);System.out.println(“3“+3+3);What will be

12、printed to standard out? A. 333 and 333 B. 63 and 63 C. 333 and 63 D. 63 and 333(分数:3.00)A.B.C.D.10.Consider the interface CharSequence that is a required argument in one of the replace method declarations:public String replace(CharSequence target, CharSequence replacement) .This CharSequence interf

13、ace is a super interface to which concrete classes? A. String B. StringBoxer C. StringBuffer D. StringBuilder(分数:3.00)A.B.C.D.11.Which statement is false about the toString method? A. The toString method is a method of the Object class. B. The toString method returns a string representation of the o

14、bject. C. The toString method must return the objects state information in the form of a string. D. The toString method is commonly overridden.(分数:3.00)A.B.C.D.12.Which indexOf method declaration is invalid? A. indexOf(int ch) B. indexOf(int ch, int fromlndex) C. indexOf(String str, int fromlndex) D

15、. indexOf(CharSequence str, int fromlndex)(分数:3.00)A.B.C.D.13.Given:String tenCharString = “AAAAAAAAAA“;System.out.println(tenCharString.replace(“AAA“, “LLL“);What is printed to the standard out? A. AAAAAAAAAA B. LLLAAAAAAA C. LLLLLLLLLA D. LLLLLLLLLL(分数:3.00)A.B.C.D.14.Consider the following illust

16、ration. Which statements, also represented in the illustration, are true?(分数:3.00)A.B.C.D.15.Which declaration of the StringBuilder class exists? A. public StringBuilder reverse(String str) . B. public StringBuilder reverse(int index, String str) . C. public StringBuilder reverse() . D. All of the a

17、bove(分数:3.00)A.B.C.D.16.Given: String name1 = new String(“Benjamin“); StringBuilder name2 = new StringBuilder(“Benjamin“); System.out.println(name2.equals(name1); Are the String and StringBuilder classes of comparable types? Select the correct statement. A. The String and StringBuilder classes are c

18、omparable types. B. The String and StringBuilder classes are incomparable types.(分数:3.00)A.B.17.You need to create an application that is used to calculate the attendance at a baseball game. What data type would be most appropriate for storing the attendance? A. boolean B. char C. float D. int(分数:3.

19、00)A.B.C.D.18.What is the best data type to use if you are required to perform many addition, subtraction, and multiplication calculations on a whole number? A. double B. Double C. int D. Integer(分数:3.00)A.B.C.D.19.You are writing a class that will store the status of an on/off switch. Which data ty

20、pe is most appropriate for storing this value? A. boolean B. char C. short D. int(分数:3.00)A.B.C.D.20.You have decided on the data type for a variable that will store the information about the on/off switch. Now you must determine a name for it. Which of the following names follows the Java naming co

21、nventions? A. LIGHTSWITCHENABLED B. LightSwitchEnabled C. lightSwitchEnabled D. x(分数:3.00)A.B.C.D.21.What is the best data type to use when storing a status code that may have one of the following values: success, failed, success with errors, or undetermined? A. Object B. Class C. boolean D. enum E.

22、 int(分数:3.00)A.B.C.D.E.22.A system has three sensors attached to it. You need a way to represent this system in your program. What would be the best data type to use to model this system and sensors? A. Object B. boolean C. enum D. int(分数:3.00)A.B.C.D.23.The new keyword is used to initialize which o

23、f the following data types? (Choose all that apply.) A. Object B. boolean C. Boolean D. Float E. float F. float(分数:3.00)A.B.C.D.E.F.24.In the following line of code, what does the (int) represent?number = (int)sensorReading; A. Rounding the sensorReading variable to the nearest int. B. Casting the s

24、ensorReading variable to the int data type. C. Nothing; it is there as a comment.(分数:3.00)A.B.C.25.Given the following line of code, which of the lines of code listed are incorrect? (Choose all that apply.)char c; A. c = new char(); B. c = Y; C. c = /u0056; D. c = “Yes“;(分数:3.00)A.B.C.D.26.Which of

25、the following variables are being set with the use of a literal? (Choose all that apply.) A. int tvChannel = 4; B. char c = 5; C. chard = /u0123; D. char e = c; E. int oldChannel = tvChannel;(分数:3.00)A.B.C.D.E.27.Given the following line of code, what lines below are valid? (Choose all that apply.)e

26、num Sports FOOTBALL, BASKETBALL, BASEBALL, TRACK A. Sports sport = FOOTBALL; B. Sports sport = Sports.FOOTBALL; C. Sports sport = Sports.HOCKEY; D. Sports sport = TRACK(分数:3.00)A.B.C.D.28.What is wrong with the following method?public double interestDue(double currentBalance, float interestRate) dou

27、ble interestDue = currentBalance * interestRate;return interestDue; A. It should use all float primitives. B. It should use all Float objects. C. It should use all double primitives. D. It should use all Double objects. E. It should use BigDecimal objects. F. Nothing is wrong with this method. G. It

28、 does not compile because you cannot do math operations with primitives that are not the same type.(分数:3.00)A.B.C.D.E.F.G.29.What is the correct way to create an array with five int data types? (Choose all that apply.) A. int intArray = new int5; B. int intArray = new int(5); C. int intArray = new i

29、nt5; D. int intArray = new int 5;(分数:3.00)A.B.C.D.30.What is the correct way to initialize a variable declared with the data type of Book , as a new Book object? A. Book b; B. Book b = new Book(); C. Book b = new Book; D. Book b = Book();(分数:3.00)A.B.C.D.31.What is the difference between an int and

30、an Integer? A. Nothing. They are both fully interchangeable. B. An int is an object and Integer is a primitive. An int is fastest when performing calculations. C. An int is a primitive and Integer is an object. An int is fastest when performing calculations. D. This is a trick question. There is no

31、such thing as an Integer. E. This is a trick question. An Integer can be defined to be anything a developer wants it to be.(分数:3.00)A.B.C.D.E.32.What is the result of using a method of an uninitialized object? A. Null is returned. B. The object is automatically initialized and an appropriate value i

32、s returned. C. A NullPointerException is thrown from the Java Virtual Machine.(分数:3.00)A.B.C.33.What is wrong with the following code segment? (Choose all that apply.) 1: float a = 1.2f; 2: int b = 5; 3: short c = 9; 4: long d = 6; 5: double e = b; 6: Double f = e; 7: Short g; 8: Float h = g.floatVa

33、lue(); A. Nothing is wrong. B. There is an error on line 1. C. There is an error on line 2. D. There is an error on line 3. E. There is an error on line 4. F. There is an error on line 5. G. There is an error on line 6. H. There is an error on line 7. I. There is an error on line 8.(分数:2.00)A.B.C.D.

34、E.F.G.H.I.34.What is the value of variable x in the following code segment?float x =O.Of;int y = 5;long z;x = y + 3.3f;x = x+z; A. 0 B. 0.0f C. 5.0f D. 8.3f E. 8.3 F. This code will not compile.(分数:2.00)A.B.C.D.E.F.计算机 Java认证-Java 运算符和字符串编程、使用基本类和变量答案解析(总分:100.00,做题时间:90 分钟)一、B不定项选择题/B(总题数:34,分数:100

35、.00)1.Given:public class ArithmeticResultsOutput public static void main(String args) int i = 0;int j = 0;if(i+ = +j)System.out.println(“True: i=“+i+“j=“+j); else System.out.println(“False: i=“+i+“j=“+j);What will be printed to standard out? A. True: i=0, j=1 B. True: i=1, j=1 C. False: i=0, j=1 D.

36、False: i=1, j=1(分数:3.00)A.B.C.D. 解析:j 的值在计算之前已经前递增了,但是 i的值却没有。因此,表达式计算结果为 false的布尔值,因为 0不等于 1(即 i=0和 j=1)。表达式计算完之后,但在相关的打印语句执行之前,i 的值已经后递增(即(i=1)。因此,正确的答案是 False: i=1, j=1。A、B 和 C不是正确答案,理由如正确答案的解释。2.Which set of operators represents the complete set of valid Java assignment operators? A. %=, A. 23 B

37、. 3 C. 1 D. 0(分数:3.00)A.B.C.D. 解析:49/26 的余数是 23。23/5 的余数是 3。3/1 的余数是 0。答案是 0。A、B 和 C不是正确答案,理由如正确答案的解释。4.Given:public class BooleanResultsOutput public static void main(String args) boolean booleanValue1 = true;boolean booleanValue2 = false;System.out.print(!(booleanValue1 System.out.print(!(booleanV

38、alue1 | !booleanValue2)+“ “);System.out.print(!(booleanValue1 !booleanValue2);What will be printed, considering the usage of the logical Boolean operators? A. false, false, true B. false, true, true C. true, false, true D. true, true, true(分数:3.00)A. B.C.D.解析:第一个表达式语句(!(true intj1= 200;if(i1=99) els

39、e System.out.print(“Value2: “+(i1+j1+“ “);inti2=100; intj2=200;if(i2=99) else System.out.print(“Value2: “+(i2+j2+“ “);inti3=100; intj3=200;if(i3=100) | (-j3=200) System.out.print(“Value1: “+(i3+j3+“ “); else System.out.print(“Value2: “+(i3+j3+“ “);inti4=100; intj4=200;if(i4=100) | (-j4=200) System.o

40、ut.print(“Value1: “+(i4+j4+“ “); else System.out.print(“Value2: “+(i4+j4+“ “);What will be printed to standard out? A. Value2: 300 Value2: 300 Value1: 300 Value1: 300 B. Value2: 299 Value2: 300 Value1: 299 Value1: 300 C. Value1: 299 Value1: 300 Value2: 299 Value2: 300 D. Value1: 300 Value1: 299 Valu

41、e2: 300 Value2: 299(分数:3.00)A.B. C.D.解析:因为 Value2: 299 Value2: 300 Value1: 299 Value1: 300将被打印到标准输出。请注意 /prime number candidateDouble primeSquareRoot = Math.sqrt(p);boolean isPrime = true;for(long j = 2; j= primeSquareRoot.longValue(); j+) if(p % j = = 0) / Print divisorsSystem.out.println(j+“X“+p/j

42、);isPrime = false;System.out.println(“Prime number: “+isPrime);Which of the following is true? Hint: 17496 is not a prime number. A. The code will not compile due to s syntactical error somewhere in the code. B. The code will not compile since the expression (p % j = 0) should be written as (p % j)

43、= 0). C. Divisors will be printed to standard out (for example, 2x8478, and so on), along with Prime number: false as the final output. D. Divisors will be printed to standard out (for example, 2x8478, and so on), along with “Prime number: 0“ as the final output.(分数:3.00)A.B.C. D.解析:除数将会被打印到标准输出,紧随

44、Prime number: false之后。对于好奇的读者,除数的完整列表打印如下:2x8748、3x5832、4x4374、6x2916、8x2187、9x1944、12x1458、18x972、24x729、27x648、36x486、54x324、72x243、81x216 和 108x162。A、B 和 D不正确。A 不正确,因为在代码中没有语法错误。B 不正确,因为围绕 p%j的一对括号并不需要。D 不正确,因为代码不会打印出字符 0,它打印出布尔字面值false。7.Given:public class EqualityTests public static void main (

45、String args)Integer value1 = new Integer(“312“);Integer value2 = new Integer (“312“);Object object1 = new Object();Object object2 = new Object();Object object3 = value1;Which expressions evaluate to true? A. value1.equals (value2) B. value1.equals (object1) C. value1.equals (object3) D. object1.equa

46、ls (object2)(分数:3.00)A. B.C. D.解析:A 正确,因为类 Integer实现了 Comparable接口,允许使用 equals方法。C 正确,因为 Integer对象被用来创建 Object引用。B 和 D不正确,因为代码不能使两个不同引用的对象相等。8.Given:System.out.print(true | false System.out.println(false What will be printed to standard out? A. true, true B. true, false C. false, true D. false, fals

47、e E. Compilation error(分数:3.00)A.B.C.D.E. 解析:在第一个打印语句中,布尔和字符串的连接是不允许的。因此,第一行不会编译。在布尔计算中添加括号来改变语句,将允许该行编译: System.out.print(true | false 一旦这行是可编译的,正确的答案将是 A,考虑到运算优先级,布尔与(System.out.print(“and“);System.out.println(“3“+3+3);What will be printed to standard out? A. 333 and 333 B. 63 and 63 C. 333 and 63

48、 D. 63 and 333(分数:3.00)A.B.C.D. 解析:(+)运算符具有从左向右的顺序。第一条语句的前两个操作数是数字,所以使用加法(+)运算符。因此,3+3=6。因为 6+“3“使用了一个字符串作为操作数,使用字符串连接(+)运算符。因此,连接字符串 6和 3呈现字符串 63。最后一个语句的处理有一点不同。第一个操作数是字符串;因此对其他操作数使用字符串连接运算符。所以,连接字符串“3“+“3“+“3“呈现字符串 333。正确的答案是 63和 333。A、B 和 C不正确。注意,将(“3“+3+3)变成(“3“+(3+3)将呈现 36。10.Consider the interface CharSequence that is a required argument in o

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1