1、int j = 0;j = j++; 问j现在等于多少? 2、一道邪恶的Java基础题——来自JavaEye的网友 Java代码 String a = "abc"; String b = "abc"; System.out.println("====>"+ a==b ); 请问输出结果是true还是false? 3、try中包含return语句,finally是否还执行,在return之前还是之后? Java代码 public static boolean get() { try { return false; } finally { return true; } } 请大家思考一个问题,return的具体实现是怎样的?如果返回false,为什么;如果返回是true,又是为什么呢?给个你认为正确答案的理由出来。 如果在笔试(无法上机操作)的情况下,遇到这3道笔试题,大家有把握能做对几道 第一题: Java代码 public static void main(String[] args) throws Exception { int[] x = new int[6]; Arrays.fill(x, 1); for (int i = 0; i < x.length; i++) { System.in.read(); System.out.println(x); } } public static void main(String[] args) throws Exception { int[] x = new int[6]; Arrays.fill(x, 1); for (int i = 0; i < x.length; i++) { System.in.read(); System.out.println(x); } }这段代码,输入“1”(不含引号),按回车后,系统输出什么? 第二题: Java代码 private static void foo() { try { System.out.println("try"); foo(); } catch (Throwable e) { System.out.println("catch"); foo(); } finally { System.out.println("finally"); foo(); } } public static void main(String[] args) { foo(); } private static void foo() { try { System.out.println("try"); foo(); } catch (Throwable e) { System.out.println("catch"); foo(); } finally { System.out.println("finally"); foo(); } } public static void main(String[] args) { foo(); }上述代码运行后: A.执行一段时间后报栈溢出。 B.会一直输出“try”。 C.会一直输出“try”和“finally”。 D.会一直输出“try”、“catch”和“finally” 第三题: Java代码 A = 1; System.out.println(A); A = 1;System.out.println(A);A是一个int类型变量,请在这段代码的前、后添加任意代码(但两句之间不能再插入代码),使得程序编译时第一句可以编译通过,而第二句出现编译错误。
评论列表
文章目录