java软件中级工程师笔试题复杂逻辑 下载本文

J2EE部分

1、运算符优先级问题,下面代码的结果是多少?(笔试)

package test;

public class Test {

public static void main(String[] args) { int k = 0;

int ret = ++k + k++ + ++k + k; // ret的值为多少 } }

2、运算符问题,下面代码分别输出什么?(笔试)

package test;

public class Test {

public static void main(String[] args) { int i1 = 10, i2 = 10; } }

3、下面代码的结果是什么?还是抛出异常?(笔试)

package test;

public class Test {

public void myMethod(String str) { }

public void myMethod(Object obj) { }

public static void main(String[] args) { Test t = new Test(); t.myMethod(null); } }

4、假设今天是9月8日,下面代码输出什么?(笔试)

package test;

public class Test {

public static void main(String[] args) { Date date = new Date(); } }

5、下面代码的输出结果是什么?

package test;

public class Test {

public static void main(String[] args) { double val = 11.5; } }

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(); }

@Override

public void method() { } }

class Base {

public void method() throws InterruptedException { } }

7、以下代码的结果是什么?

package test;

public class Test extends Base {

public static void main(String[] args) { new Test().method(); }

public void method() { } }

class Base { }

8、true or false?

package test;

public class Test {

public static void main(String[] args) {

}

}

String str1 = new String(\String str2 = new String(\

StringBuffer sb1 = new StringBuffer(\StringBuffer sb2 = new StringBuffer(\

9、输出的结果是什么?

package test;

public class Test {

public static void main(String[] args) { }

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) { }

public static boolean method() { try {

return true; } finally { return false; } } }