




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
J2EE部分1、运算符优先级问题,下面代码的结果是多少?(笔试)package test;public class Test public static void main(String args) int k = 0;int ret = +k + k+ + +k + k;/ ret的值为多少System.err.println(ret);2、运算符问题,下面代码分别输出什么?(笔试) package test;public class Test public static void main(String args) int i1 = 10, i2 = 10;System.err.println(i1 + i2 = + i1 + i2);System.err.println(i1 - i2 = + i1 - i2);System.err.println(i1 * i2 = + i1 * i2);System.err.println(i1 / i2 = + i1 / i2);3、下面代码的结果是什么?还是抛出异常?(笔试) package test;public class Test public void myMethod(String str) System.err.println(string);public void myMethod(Object obj) System.err.println(object);public static void main(String args) Test t = new Test();t.myMethod(null);4、假设今天是9月8日,下面代码输出什么?(笔试) package test;import java.util.Date;public class Test public static void main(String args) Date date = new Date();System.err.println(date.getMonth() + + date.getDate();5、下面代码的输出结果是什么? package test;public class Test public static void main(String args) double val = 11.5;System.err.println(Math.round(val);System.err.println(Math.floor(val);System.err.println(Math.ceil(val);6、下面代码的结果是什么?package test;public class Test extends Base public static void main(String args) Base b = new Test();b.method();Test t = new Test();t.method();Overridepublic void method() System.err.println(test);class Base public void method() throws InterruptedException System.err.println(base);7、以下代码的结果是什么? package test;public class Test extends Base public static void main(String args) new Test().method();public void method() System.err.println(super.getClass().getName();System.err.println(this.getClass().getSuperclass().getName();class Base 8、true or false?package test;public class Test public static void main(String args) String str1 = new String(abc);String str2 = new String(abc);System.err.println(str1.equals(str2);StringBuffer sb1 = new StringBuffer(abc);StringBuffer sb2 = new StringBuffer(abc);System.err.println(sb1.equals(sb2);9、输出的结果是什么? package test;public class Test public static void main(String args) System.err.println(new Test().method1();System.err.println(new Test().method2();public int method1() int x = 1;try return x; finally +x;public int method2() int x = 1;try return x; finally return +x;这样呢?输出什么 package test;public class Test public static void main(String args) System.err.println(method();public static boolean method() try return true; finally return false; 10、方法m1和m2有区别吗?什么区别 package test;public class Test public static void main(String args) public synchronized void m1() public static synchronized void m2() 11、true or false?理由 package test;public class Test public static void main(String args) Integer i1 = 127;Integer i2 = 127;System.err.println(i1 = i2);i1 = 128;i2 = 128;System.err.println(i1 = i2);12、true or false?理由 package test;public class Test public static void main(String args) String str1 = a;String str2 = a;String str3 = new String(a);System.err.println(str1 = str2);System.err.println(str1 = str3);str3 = ern();System.err.println(str1 = str3);13、true or false?理由 package test;public class Test public static void main(String args) System.err.println(12 - 11.9 = 0.1);14、以下代码输出是什么? package test;import java.math.BigInteger;public class Test public static void main(String args) BigInteger one = new BigInteger(1);BigInteger two = new BigInteger(2);BigInteger three = new BigInteger(3);BigInteger sum = new BigInteger(0);sum.add(one);sum.add(two);sum.add(three);System.out.println(sum.toString();15、输出的结果是什么?12345?根据单词排序?还是? package test;import java.util.HashSet;import java.util.Iterator;import java.util.Set;public class Test public static void main(String args) Set set = new HashSet();set.add(one);set.add(two);set.add(three);set.add(four);set.add(five);for (Iterator it = set.iterator(); it.hasNext();) System.err.println(it.next();16、以下代码输出的结果(笔试选择题)public class Test public static void main(String args) System.err.println(args.length);A. nullB. 0C. TestD. Exception in thread main java.lang.NullPointerException17、下面为一个单例的实现代码,请指出代码中有几个错误或不合理之处,并改正。public class Test public Test instance = null;public static Test getInstance() if (instance = null) instance = new Test();return instance;18、编程输出一个目录下的所有目录及文件名称,目录之间用tab。(笔试) 19、从键盘读入10个整数,然后从大到小输出。(笔试)20、如何迭代Map容器,手写个试试?答案:1、82、i1 + i2 = 1010语法错误i1 * i2 = 100i1 / i2 = 13、string4、5 195、1211.012.06、testtest7、test.Testtest.Base8、truefalse9、12false10、A: synchronized static是某个类的范围,synchronized static cSync防止多个线程同时访问这个类中的synchronized static 方法。它可以对类的所有对象实例起作用。B: synchronized 是某实例的范围,synchronized isSync()防止多个线程同时访问这个实例中的synchronized 方法。11、truefalse12、truefalsetrue13、false14、015、twofiveonethreefour16、B17、getInstance 无默认返回值instance必须是static18、package test;import java.io.File;public class Test public static void main(String args) new Test().read(D:/test, );public void read(String path, String tab) File file = new File(path);File childFiles = file.listFiles();for (int i = 0; childFiles != null & i childFiles.length; i+) System.err.println(tab + childFilesi.getName();if (childFilesi.isDirectory() read(childFilesi.getPath(), tab + t);19、package test;import java.util.Arrays;import java.util.Comparator;import java.util.Scanner;public class Test public static void main(String args) Scanner in = new Scanner(System.in);/ 注意这里的数组,不是int的Integer arr = new Integer10;for (int i = 0; i 10; i+) arri = in.nextInt();Arrays.sort(arr, new Comparator() Overridepublic int compare(Integer o1, Integer o2) if (o1 o2) return -1;if (o1 o2) return 1;return 0;);System.err.println(Arrays.toString(arr);20、package test;import java.util.HashMap;import java.util.Iterator;import java.util.Map;import java.util.Map.Entry;import java.util.Set;publ
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 钢材公司的合同范本
- 委托转租门面合同范本
- 2017租房协议合同范本
- 青少年读本出版合同
- 新租赁厂房合同范本
- 入户空间租房合同范本
- 公路承包开挖合同范本
- 混合型肠易激综合征护理查房
- 成套电器销售合同范本
- 2008租赁合同范本
- 英汉互译单词练习打印纸
- 四川JS-004竣工验收报告
- 花卉栽植施工方案
- 水工闸门课件
- 水泥生产企业生产安全事故综合应急预案
- 全自动血液细胞分析仪产品技术要求深圳迈瑞
- 找对英语学习方法的第一本书
- 安徽涵丰科技有限公司年产6000吨磷酸酯阻燃剂DOPO、4800吨磷酸酯阻燃剂DOPO衍生品、12000吨副产品盐酸、38000吨聚合氯化铝、20000吨固化剂项目环境影响报告书
- 《诺丁山》经典台词
- 对铁路机车乘务员规章培训的探讨与实践
- 临床医学实验室 仪器设备一览表格模板
评论
0/150
提交评论