JAVA测试题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
JA V A第一次测试题
Question No: 1
Given:
Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);
Which two expressions evaluate to True? (Choose Two)
A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))
Question No: 2
Which two statements are true for the class java.util.TreeSet? (Choose two)
A. The elements in the collection are ordered.
B. The collection is guaranteed to be immutable.
C. The elements in the collection are guaranteed to be unique.
D. The elements in the collection are accessed using a unique key.
E. The elements in the collection are guaranteed to be synchronized
Question No: 3
What happens when you try to compile and run the following application? Choose all correct options.
1. public class Z {
2. public static void main(String[] args) {
3. new Z();
4. }
5.
6. Z() {
7. Z alias1 = this;
8. Z alias2 = this;
9. synchronized(alias1) {
10. try {
11. alias2.wait();
12. System.out.println(“DONE WAITING”);
13. }
14. catch (InterruptedException e) {
15. System.out.println(“INTERR UPTED”);
16. }
17. catch (Exception e) {
18. System.out.pr intln(“OTHER EXCEPTION”);
19. }
20. finally {
21. System.out.println (“FINALLY”);
22. }
23. }
24. System.out.println(“ALL DONE”);
25. }
26. }
A. The application compiles but doesn't print anything.
B. The application compiles and print “DONE WAITING”
C. The application compiles and print “FINALLY”
D. The application compiles and print “ALL DONE”
E. The application compiles and print “INTERRUPTED”
Question No: 4
True or False: Readers have methods that can read and return floats and doubles.
A. Ture
B. False
Question No: 5
Which two demonstrate a "has a" relationship? (Choose two)
A.
public interface Person { }
public class Employee extends Person{ }
B.
public interface Shape { }
public interface Rectandle extends Shape { }
C.
public interface Colorable { }
public class Shape implements Colorable { }
D.
public class Species{ }
public class Animal{private Species species;}
E.
interface Component{ }
class Container implements Component{
private Component[] children;
}
Question No: 6
Which of the following lines of code will compile without error?
A.