1 / 12
文档名称:

Java笔试题.doc

格式:doc   大小:46KB   页数:12
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

Java笔试题.doc

上传人:mh900965 2018/1/12 文件大小:46 KB

下载得到文件列表

Java笔试题.doc

相关文档

文档介绍

文档介绍:Java 软件工程师笔试题
Question 1
Given:
public class ClassA {
public int getValue() {
int value = 0;
boolean setting = true;
String title = "Hello";
if (value || (setting && title == "Hello")) {
return 1;
}
if (value == 1 & ("Hello")) {
return 2;
}
}
public static void main(String args){
ClassA a = new ClassA();
();
}
What is the result?
A. Compilation fails.
B. 1
C. 2
D. The code runs with no output.
E. An exception is thrown at runtime.
Question 2
Given:
public class Test {
public void testIfA() {
if (testIfB("True")) {
("true");
} else {
("not true");
}
}
public Boolean testIfB(String str) {
return (str);
}
public static void main(String[] args) {
Test t = new Test();
();
}
}
What is the result when method testIfA is invoked?
An exception is thrown at runtime.
true
C. not true
D. Compilation fails
Question 3
Given:
11. public static void main(String[] args) {
12. Integer i = new Integer(1) + new Integer(2);
13. switch(i) {
14. case 3: (" three ");
15. default: (" other ");
16. }
17. }
What is the result?
A. three
B. other
C. three other
D. Compilation fails because of an error on line 12.
E. Compilation fails because of an error on line 13.
F. Compilation fails because of an error on line 15.
Question 4
Given:
11. public static void main(String[] args) {
12. String str = "null";
13. if (str == null) {
14. ("null");
15. } else (() == 0) {
16. ("zero");
17. } else {
18. ("some");
19. }
20. }
What is the result?
A. null
B. zero
C. some
D. Compilation fails.
E. An exception is thrown at runtime.
Question 5
Given:
int x = 0;
int y = 10;
do {
y--;
++x;
} while (x < 5);
(x + "," + y);
What is the result?
A. 5,6
B. 5,5
C. 6,5
D. 6,6
Question 6
Given:
35.