Java认证考试 题目列表
Which EL expression evaluates to the request URI?()A、${requestURI}B、${request.URI}C、${request.getURI}D、${request.requestURI}E、${requestScope.requestURI}F、${pageContext.request.requestURI}
One of the use cases in your web application uses many session-scoped attributes. At the end of the usecase, you want to clear out this set of attributes from the session object. Assume that this static variableholds this set of attribute names: 201.private static final Set USE_CASE_ATTRS; 202.static { 203.USE_CASE_ATTRS.add("customerOID"); 204.USE_CASE_ATTRS.add("custMgrBean"); 205.USE_CASE_ATTRS.add("orderOID"); 206.USE_CASE_ATTRS.add("orderMgrBean"); 207.} Which code snippet deletes these attributes from the session object?()A、session.removeAll(USE_CASE_ATTRS);B、for( String attr : USE_CASE_ATTRS ){ session.remove(attr); }C、for( String attr : USE_CASE_ATTRS ){session.removeAttribute(attr);}D、for( String attr : USE_CASE_ATTRS ){session.deleteAttribute(attr);}E、session.deleteAllAttributes(USE_CASE_ATTRS);
A developer is designing a web application that must support multiple interfaces, including: • an XML web service for B2B • HTML for web-based clients • WML for wireless customers Which design pattern provides a solution for this problem?( )A、 Session FaçadeB、 Business DelegateC、 Data Access ObjectD、 Model-View-ControllerE、 Chain of Responsibility
关于自加运算符“++”,下列说法中正确的是()A、 “OP++”和“++OP”虽然都有让OP的值加一的作用,但返回的值不同。B、 “OP++”和“++OP”的作用相同,都是让OP的值加一。C、 “OP++”的作用是先将OP自身的值加一,再返回自加以后的值。D、 “++OP”的作用是先返回OP的值,再将OP自身的值加一。
public class TestFive { private int x; public void foo() { int current = x; x = current + 1; } public void go() { for(int i=0;i5;i++) { new Thread() { public void run() { foo(); System.out.print(x + “, “); } }.start(); }}} Which two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5, ?()A、 Move the line 12 print statement into the foo() method.B、 Change line 7 to public synchronized void go() {.C、 Change the variable declaration on line 3 to private volatile int x;.D、 Wrap the code inside the foo() method with a synchronized( this ) block.E、 Wrap the for loop code inside the go() method with a synchronized block synchronized(this) { // for loop code here }.
10. class MakeFile { 11. public static void main(String[] args) { 12. try { 13. File directory = new File(”d”); 14. File file = new File(directory,”f”); 15. if(!file.exists()) { 16. file.createNewFile(); 17. } 18. } catch (IOException e) { 19. e.printStackTrace 20. } 21. } 22. } The current directory does NOT contain a directory named “d.” Which three are true?()A、 Line 16 is never executed.B、 An exception is thrown at runtime.C、 Line 13 creates a File object named “d”.D、 Line 14 creates a File object named “f‟.E、 Line 13 creates a directory named “d” in the file system.F、 Line 16 creates a directory named “d” and a file “f” within it in the file system.G、 Line 14 creates a file named "f " inside of the directory named “d” in the file system.
下面正确的创建 Socket 的语句是()A、 Socket a = new Soeket(80):B、 Socket b = new Socket("130. 3. 4. 5", 80):C、 ServerSocket c = new Socket(80)D、 ServerSocket d = new Socket ("130. 3. 4, 5", 80)
定义枚举如下: public enum Direction{ EAST,SOUTH,WEST,NORTH } 下列正确使用该枚举类型的语句是哪项?() A、Direction Direction=EAST;B、Direction direction=Direction.WEST;C、int a- Direction.NORTH;D、Direction direction=2;
1. package foo; 2. 3. import java.util.Vector; 4. 5. protected class MyVector Vector { 6. init i = 1; 7. public MyVector() { 8. i = 2; 9. } 10. } 11. 12. public class MyNewVector extends MyVector { 13. public MyNewVector() { 14. i = 4; 15. } 16. public static void main(String args[]) { 17. MyVector v = new MyNewVector(); 18. } 19. } What is the result?() A、 Compilation succeeds.B、 Compilation fails because of an error at line 5.C、 Compilation fails because of an error at line 6.D、 Compilation fails because of an error at line 14.E、 Compilation fails because of an error at line 17.