Java软件中年级工程师笔试题复杂逻辑

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

J2E E部分

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("abc");

String str2 = new String("abc");

StringBuffer sb1 = new StringBuffer("abc");

StringBuffer sb2 = new StringBuffer("abc");

}

}

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;

}

}

}

10、方法m1和m2有区别吗?什么区别

package test;

public class Test {

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

public synchronized void m1() {

}

public static synchronized void m2() {

}

}

相关文档
最新文档