单选题Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 2

题目
单选题
Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 25 to properly invoke the next filter in the chain,or the target servlet if thereare no more filters?()
A

chain.forward(request, response);

B

chain.doFilter(request, response);

C

request.forward(request, response);

D

request.doFilter(request, response);


相似考题
更多“单选题Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 2”相关问题
  • 第1题:

    Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()

    • A、An IllegalStateException is thrown at runtime.
    • B、An InvalidSessionException is thrown at runtime.
    • C、The string "value=null" appears in the response stream.
    • D、The string "value=myAttributeValue" appears in the response stream.

    正确答案:A

  • 第2题:

    Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?()    public class Qf575 {   // insert declaration of a native method here   }  

    • A、native public void setTemperature(int kelvin);
    • B、private native void setTemperature(int kelvin);
    • C、protected int native getTemperature();
    • D、public abstract native void setTemperature(int kelvin);
    • E、native int setTemperature(int kelvin) {}

    正确答案:A,B

  • 第3题:

    1. public class A {  2. public void method1() {  3. B b=new B();  4. b.method2();  5. // more code here  6. }  7. }  1. public class B {  2. public void method2() {  3.C c=new C();  4. c.method3();  5. // more code here  6. }  7. }  1. public class C {  2. public void method3() {  3. // more code here  4. }  5. }  Given:  25. try {  26. A a=new A();  27. a.method1();  28. } catch (Exception e) {  29. System.out.print(”an error occurred”);  30. }  Which two are true if a NullPointerException is thrown on line 3 of class C?()

    • A、 The application will crash.
    • B、 The code on line 29 will be executed.
    • C、 The code on line 5 of class A will execute.
    • D、 The code on line 5 of class B will execute.
    • E、 The exception will be propagated back to line 27.

    正确答案:B,E

  • 第4题:

    Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 25 to properly invoke the next filter in the chain,or the target servlet if thereare no more filters?()

    • A、chain.forward(request, response);
    • B、chain.doFilter(request, response);
    • C、request.forward(request, response);
    • D、request.doFilter(request, response);

    正确答案:B

  • 第5题:

    Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()


    正确答案:super.print();

  • 第6题:

    Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()

    • A、 public void foo() { /* more code here */ }
    • B、 private void foo() { /* more code here */ }
    • C、 protected void foo() { /* more code here */ }
    • D、 int foo() { /* more code here */ }  
    • E、 void foo() { /* more code here */ }

    正确答案:A,C,E

  • 第7题:

    You develop a Windows Communication Foundation (WCF) service to generate reports. Client applications call the service to initiate report generation but do not wait for the reports to be generated. The service does not provide any status to the client applications. The service class is defined as follows. (Line numbers are included for reference only.) 01 [ServiceContract] 02 public class ReportGeneratorService 03 { 04 ... 05 private int GenerateReports(int clientID) 06 { 07 ... 08 return 0; 09 } 10 } You need to ensure that client applications can initiate reports without waiting for status. Which two actions should you perform (Each correct answer presents part of the solution. Choose two.) ()。

    • A、Insert the following code at line 04. [OperationContract(IsOneWay=true)]
    • B、Insert the following code at line 04. [OperationContract(AsyncPattern=false)]
    • C、At line 05, change the GenerateReports method from private to public.
    • D、Remove line 08. At line 05, change the return type of GenerateReports method to void.

    正确答案:A,D

  • 第8题:

    单选题
    You are developing a Windows Communication Foundation (WCF) service to replace an existing ASMX Web service.The WCF service contains the following code segment. (Line numbers are included for reference only.) 01 [ServiceContract( )] 02 03 public interface IEmployeeService 04 { 05 [OperationContract( )] 06 EmployeeInfo GetEmployeeInfo(int employeeID); 07 08 } 09 10 public class EmployeeService : IEmployeeService 11 { 12 13 public EmployeeInfo GetEmployeeInfo(int employeeID) 14 { 15 ... 16 } 17 } 18 19 20 public class EmployeeInfo 21 { 22 ... 23 public int EmployeeID { get; set; } 24 public string FirstName { get; set; } 25 public string LastName { get; set; } 26 27 }The existing Web service returns the EmployeelD as an attribute of the Employeelnfo element in the response XML.You need to ensure that applications can consume the service without code changes in the client. What should you do?()
    A

    Insert the following code at line 02. [DataContractFormat()] Insert the following code at line 22. [DataMember()]

    B

    Insert the following code at line 02. [XmlSerializerFormat()] Insert the following code at line 22. [XmlAtttibute()]

    C

    Insert the following code at line 09. [XmlSerializerFormat()] Insert the following code at line 22. [XmlAttribute()]

    D

    Insert the following code at line 19. [DataContractFormat()] Insert the following code at line 22. [DataMember()]


    正确答案: C
    解析: 暂无解析

  • 第9题:

    单选题
    1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()
    A

     Line 33 must be called within a try block.

    B

     The exception thrown by method1 in class a is not required to be caught.

    C

     The method declared on line 31 must be declared to throw a RuntimeException.

    D

     On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.


    正确答案: A
    解析: 暂无解析

  • 第10题:

    单选题
    Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here26. } Which should you insert at line 25 to properly invoke the next filter in the chain,or the target servlet if thereare no more filters?()
    A

    chain.forward(request, response);

    B

    chain.doFilter(request, response);

    C

    request.forward(request, response);

    D

    request.doFilter(request, response);


    正确答案: D
    解析: 暂无解析

  • 第11题:

    单选题
    You need to create a class definition that is interoperable along with COM.You need to ensure that COM applications can create instances of the class and can call the GetAddress method. Which code segment should you use?()
    A

    A

    B

    B

    C

    C

    D

    D


    正确答案: A
    解析: 暂无解析

  • 第12题:

    单选题
    Given a Filter class definition with this method: 21.public void doFilter(ServletRequest request, 22.ServletResponse response, 23.FilterChain chain) 24.throws ServletException, IOException { 25.// insert code here 26.} Which should you insert at line 25 to properly invoke the next filter in the chain, or the target servlet if thereare no more filters?()
    A

    chain.forward(request, response);

    B

    chain.doFilter(request, response);

    C

    request.forward(request, response);

    D

    request.doFilter(request, response);


    正确答案: A
    解析: 暂无解析

  • 第13题:

    1. public class a {  2. public void method1() {  3. try {  4. B b=new b();  5. b.method2();  6. // more code here  7. } catch (TestException te) {  8. throw new RuntimeException(te);  9. }  10. }  11. }  1. public class b {  2. public void method2() throws TestException {  3. // more code here  4. }  5. }  1. public class TestException extends Exception {  2. }  Given:  31. public void method() {  32. A a=new a();  33. a.method1();  34. }  Which is true if a TestException is thrown on line 3 of class b?()

    • A、 Line 33 must be called within a try block.
    • B、 The exception thrown by method1 in class a is not required to be caught.
    • C、 The method declared on line 31 must be declared to throw a RuntimeException.
    • D、 On line 5 of class a, the call to method2 of class b does not need to be placed in a try/catch block.

    正确答案:B

  • 第14题:

    class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()

    • A、 int foo() { /* more code here */ }
    • B、 void foo() { /* more code here */ }
    • C、 public void foo() { /* more code here */ }
    • D、 private void foo() { /* more code here */ }
    • E、 protected void foo() { /* more code here */ }

    正确答案:B,C,E

  • 第15题:

    Given: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.// insert code here 16.} 17.} and this element in the web application’s deployment descriptor: 302 /html/error.html Which,inserted at line 15,causes the container to redirect control to the error.html resource?()

    • A、response.setError(302);
    • B、response.sendError(302);
    • C、response.setStatus(302);
    • D、response.sendRedirect(302);
    • E、response.sendErrorRedirect(302);

    正确答案:B

  • 第16题:

    Given: 10.public void service(ServletRequest request, 11.ServletResponse response) { 12.ServletInputStream sis = 13.// insert code here 14.} Which retrieves the binary input stream on line 13?()

    • A、request.getWriter();
    • B、request.getReader();
    • C、request.getInputStream();
    • D、request.getResourceAsStream();

    正确答案:C

  • 第17题:

    You want to create a filter for your web application and your filter will implement javax.servlet.Filter. Which two statements are true?()

    • A、Your filter class must implement an init method and a destroy method.
    • B、Your filter class must also implement javax.servlet.FilterChain.
    • C、When your filter chains to the next filter, it should pass the same arguments it received in its doFiltermethod.
    • D、The method that your filter invokes on the object it received that implements javax.servlet.FilterChaincan invoke either another filter or a servlet.
    • E、Your filter class must implement a doFilter method that takes, among other things, anHTTPServletRequest object and an HTTPServletResponse object.

    正确答案:A,D

  • 第18题:

    You are developing a Windows Communication Foundation (WCF) service to replace an existing ASMX Web service.The WCF service contains the following code segment. (Line numbers are included for reference only.) 01 [ServiceContract( )] 02 03 public interface IEmployeeService 04 { 05 [OperationContract( )] 06 EmployeeInfo GetEmployeeInfo(int employeeID); 07 08 } 09 10 public class EmployeeService : IEmployeeService 11 { 12 13 public EmployeeInfo GetEmployeeInfo(int employeeID) 14 { 15 ... 16 } 17 } 18 19 20 public class EmployeeInfo 21 { 22 ... 23 public int EmployeeID { get; set; } 24 public string FirstName { get; set; } 25 public string LastName { get; set; } 26 27 }The existing Web service returns the EmployeelD as an attribute of the Employeelnfo element in the response XML.You need to ensure that applications can consume the service without code changes in the client. What should you do?()

    • A、Insert the following code at line 02. [DataContractFormat()] Insert the following code at line 22. [DataMember()]
    • B、Insert the following code at line 02. [XmlSerializerFormat()] Insert the following code at line 22. [XmlAtttibute()]
    • C、Insert the following code at line 09. [XmlSerializerFormat()] Insert the following code at line 22. [XmlAttribute()]
    • D、Insert the following code at line 19. [DataContractFormat()] Insert the following code at line 22. [DataMember()]

    正确答案:B

  • 第19题:

    多选题
    Given:   10. class One {   11. void foo() { }   12. }   13. class Two extends One {   14. //insert method here   15. }   Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    public void foo() { /* more code here */ }

    B

    private void foo() { /* more code here */ }

    C

    protected void foo() { /* more code here */ }

    D

    int foo() { /* more code here */ }

    E

    void foo() { /* more code here */ }


    正确答案: A,C,E
    解析: 暂无解析

  • 第20题:

    单选题
    Given: 10.public void service(ServletRequest request, 11.ServletResponse response) { 12.ServletInputStream sis = 13.// insert code here 14.} Which retrieves the binary input stream on line 13?()
    A

    request.getWriter();

    B

    request.getReader();

    C

    request.getInputStream();

    D

    request.getResourceAsStream();


    正确答案: C
    解析: 暂无解析

  • 第21题:

    单选题
    Given the definition of MyServlet: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.HttpSession session = request.getSession(); 16.session.setAttribute("myAttribute","myAttributeValue"); 17.session.invalidate(); 18.response.getWriter().println("value=" + 19.session.getAttribute("myAttribute")); 20.} 21.} What is the result when a request is sent to MyServlet?()
    A

    An IllegalStateException is thrown at runtime.

    B

    An InvalidSessionException is thrown at runtime.

    C

    The string value=null appears in the response stream.

    D

    The string value=myAttributeValue appears in the response stream.


    正确答案: C
    解析: 暂无解析

  • 第22题:

    单选题
    Given an HttpServletRequest request and an HttpServletResponse response: 41.HttpSession session = null; 42.// insert code here 43.if(session == null) { 44.// do something if session does not exist 45.} else { 46.// do something if session exists47. } To implement the design intent,which statement must be inserted at line 42?()
    A

    session = response.getSession();

    B

    session = request.getSession();

    C

    session = request.getSession(true);

    D

    session = request.getSession(false);

    E

    session = request.getSession(jsessionid);


    正确答案: A
    解析: 暂无解析

  • 第23题:

    多选题
    class One {  void foo() {}  }  class Two extends One {   //insert method here  }  Which three methods, inserted individually at line 14, will correctly complete class Two?()
    A

    int foo() { /* more code here */ }

    B

    void foo() { /* more code here */ }

    C

    public void foo() { /* more code here */ }

    D

    private void foo() { /* more code here */ }

    E

    protected void foo() { /* more code here */ }


    正确答案: C,D
    解析: 暂无解析

  • 第24题:

    单选题
    Given: 11.public class MyServlet extends HttpServlet { 12.public void service(HttpServletRequest request, 13.HttpServletResponse response) 14.throws ServletException, IOException { 15.// insert code here 16.} 17.} and this element in the web application’s deployment descriptor: 302 /html/error.html Which,inserted at line 15,causes the container to redirect control to the error.html resource?()
    A

    response.setError(302);

    B

    response.sendError(302);

    C

    response.setStatus(302);

    D

    response.sendRedirect(302);

    E

    response.sendErrorRedirect(302);


    正确答案: A
    解析: 暂无解析