Java软件中级工程师笔
试题复杂逻辑
Revised at 2 pm on December 25, 2020.
J2EE部分
1、运算符优先级问题,下面代码的结果是多少(笔试)
package test;
public class Test { public static void main(String[] args) { int k = 0; int ret = ++k + k++ + ++k + k; ethod(); } 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; } } }
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; i1 = 128; i2 = 128; } }
12、true or false?理由
package test;
public class Test { public static void main(String[] args) { String str1 = \ String str2 = \ String str3 = new String(\ str3 = (); } }
13、true or false?理由
package test;
public class Test { public static void main(String[] args) { } }
14、以下代码输出是什么
package test;
public class Test { public static void main(String[] args) { BigInteger one = new BigInteger(\ BigInteger two = new BigInteger(\ BigInteger three = new BigInteger(\ BigInteger sum = new BigInteger(\ (one); (two); (three); } }
15、输出的结果是什么12345根据单词排序还是
package test;
public class Test { public static void main(String[] args) { Set
16、以下代码输出的结果(笔试选择题)
public class Test { public static void main(String[] args) { } }
A. null B. 0 C. Test
17、下面为一个单例的实现代码,请指出代码中有几个错误或不合理之处,并改正。public class Test { public Test instance = null; public static Test getInstance() { if (instance == null) { instance = new Test(); return instance; }