【计算机类职业资格】计算机Java认证-Java运算符和字符串编程、使用基本类和变量及答案解析.doc
《【计算机类职业资格】计算机Java认证-Java运算符和字符串编程、使用基本类和变量及答案解析.doc》由会员分享,可在线阅读,更多相关《【计算机类职业资格】计算机Java认证-Java运算符和字符串编程、使用基本类和变量及答案解析.doc(26页珍藏版)》请在麦多课文档分享上搜索。
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
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
5000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 职业资格 JAVA 认证 运算 字符串 编程 使用 基本 变量 答案 解析 DOC

链接地址:http://www.mydoc123.com/p-1336858.html