java基础测试.doc_第1页
java基础测试.doc_第2页
java基础测试.doc_第3页
java基础测试.doc_第4页
java基础测试.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

QUESTION 1:Which two cause a compiler error? (Choose two) AB A. float = new float(3);B. float f2 = new float;C. float f1 = new float3; D. float f3 = new float3;E. float f5 = 1.0f, 2.0f, 2.0f ;F. float f4 = new float 1.0f,2.0f,3.0f;QUESTION 2:Given:11. int i =1,j =10;12. do 13. if(i+ -j) 14. continue;15. 16. while (i j) 14. break;15. 16. j-;17. while (+i 5);18. System.out.println(i = +i+ and j = +j); What is the result? DA. i = 6 and j = 5B. i = 5 and j = 5C. i = 6 and j = 4D. i = 5 and j = 6E. i = 6 and j = 6QUESTION 4:Given:11. int x = 3;12. int y = 1;13. if (x = y) 14. System.out.println(x = + x);15. What is the result? CA. x = 1B. x = 3C. Compilation fails.D. The code runs with no output.E. An exception is thrown at runtime. QUESTION 5:Given:1. public class Delta 2. static boolean foo(char c) 3. System.out.print(c);4. return true;5. 6. public static void main( String argv ) 7. int i =0;8. for ( foo(A); foo(B)&(i2); foo(C)9. i+ ;10. foo(D);12. 13. 14. What is the result? AA. ABDCBDCBB. ABCDABCDC. Compilation fails.D. An exception is thrown at runtime. QUESTION 6:1. public class ArrayTest 2. public static void main(String args) 3. float fl, f2;4. fl = new float10;5. f2 = f1;6. System.out.println(f20= + f20);7. 8. What is the result? CA. It prints f20 = 0.0. B. It prints f20 = NaN.C. An error at line 5 causes compile to fail. D. An error at line 6 causes compile to fail.E. An error at line 6 causes an expectation at runtime.QUESTION 7:public class Person public int aMethod() static int i = 0;i+;return i;public static void main(String args) Person test = new Person();test.aMethod();int j = test.aMethod();System.out.println(j);What is the result? DA. 0B. 1C. 2D. Compilation fails.QUESTION 8:Given:public class Person public int aMethod() static int i = 0;i+;return i;public static void main(String args) Person test = new Person();test.aMethod();int j = test.aMethod();System.out.println(j);What is the result? DA. j = -1B. j = 0C. j = 1D. j = 2E. Compilation fails.QUESTION 9:Given:boolean bool = true; if(bool = false) System.out.println(a); else if (bool) System.out.println(b); else if (!bool) System.out.println(c); else System.out.println(d); What is the result? CAa BbCc DdQUESTION 10:Given:10. int i = 0;11. for (; i 4; i += 2) 12. System.out.print(i + );13. 14. System.out.println(i); What is the result? AA. 0 2 4B. 0 2 4 5C. 0 1 2 3 4D. Compilation fails.E. An exception is thrown at runtime.QUESTION 11:Given:public class SwitchTest public static void main(String args) System.out.println(value = + switchIt(4);public static int switchIt(int x) int j = 1;switch (x) case 1:j+;case 2:j+;case 3:j+;case 4:j+;case 5:j+;default:j+;return j + x; What is the result? EA. value = 4B. value =5C. value = 6D. value = 7E. value = 8QUESTION 12:public static void main(String args) boolean flag;int i = 0;do flag = false;System.out.println(i+);flag = i 10;continue; while (flag) ? true : false);What is the result? EA. 000000000B. 0123456789C. Compilation fails.D. The code runs with no output.E. The code enters an infinite loop.F. An exception is thrown at runtime.QUESTION 13:11. int i = 1,j = -1;12. switch (i) 13. case 0, 1:j = 1;14. case 2: j = 2;15. default; j = 0;16. 17. System.out.println(j=+j); What is the result? BA. j = -1B. j = 0C. j = 1D. j = 2E. Compilation fails.QUESTION 14:Given:public static void main(String args) for (int i =0; i 3; i+) switch(i) case 0: break; case 1: System.out.print(one ); case 2: System.out.print(two ); case 3: System.out.print(three ); System.out.println(done);What is the result? DA. doneB. one two doneC. one two three doneD. one two three two three doneE. Compilation fails.QUESTION 15:Given:public class Person public int aMethod() int i

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论