A user whose role is Admin can perform a PUT.
A user whose role is Admin can perform a GET.
A user whose role is Admin can perform a POST.
A user whose role is Member can perform a PUT.
A user whose role is Member can perform a POST.
A user whose role is Member can perform a GET.
第1题:
在J2EE中,有如下代码在Servlet1.java中。 import javax.servlet.*; import javax.servlet.http.*; import java.io.IOException; import java.io.PrintWriter; public class Servlet1 extends HttpServlet { public void init() throws ServletException { } public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); out.println("hello!"); } } 假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下陈述正确的是()。
第2题:
Given: 3.public class MyTagHandler extends TagSupport { 4.public int doStartTag() { 5.// insert code here 6.// return an int 7.} 8.// more code here ... 18.} There is a single attribute foo in the session scope. Which three code fragments,inserted independently atline 5,return the value of the attribute?()
第3题:
class One { void foo() {} } class Two extends One { //insert method here } Which three methods, inserted individually at line 14, will correctly complete class Two?()
第4题:
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?()
第5题:
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:
第6题:
Given: 3.class MyServlet extends HttpServlet { 4.public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException { 5.// servlet code here ... 26.} 27.} If the DD contains a single security constraint associated with MyServlet and its only
第7题:
Given the HttpServlet code: getServletContext().setAttribute(“foo”, “value”); What is the result?()
第8题:
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
int foo() { /* more code here */ }
void foo() { /* more code here */ }
第9题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第10题:
The application will crash.
The code on line 29 will be executed.
The code on line 5 of class A will execute.
The code on line 5 of class B will execute.
The exception will be propagated back to line 27.
第11题:
编译该文件时会提示缺少doGet()或者doPost()方法,编译不能够成功通过
编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,会看到输出文字:“hello!”
编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
编译后,把Servlet1.class放在正确位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息
第12题:
chain.forward(request, response);
chain.doFilter(request, response);
request.forward(request, response);
request.doFilter(request, response);
第13题:
在J2EE中,Servlet1的代码如下: import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Servlet1 extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String aa=request.getQueryString(); String bb=request.getMethod(); out.println(aa); out.println(bb); } } 把Servlet1.class文件放在Web服务器适合的目录下,在浏览B器地址栏内输入:http://localhost:8080/servlet/Servlet1?name=jb-aptech&phone=12345678,看到的结果是()。
第14题:
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?()
第15题:
1. public class Exception Test { 2. class TestException extends Exception {} 3. public void runTest() throws TestException {} 4. public void test() /* Point X */ { 5. runTest(); 6. } 7. } At Point X on line 4, which code is necessary to make the code compile?()
第16题:
在J2EE中,有如下代码在Servlet1.java中 Import javax.servlet.*; Import javax,servlet.http.*; Import java.io,IOException; Import java.io.PrintWriter; Public class Servlet1 extends HttpServlet{ Public void init() throws ServletException{} Public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException{ PrintWriter out = reponse.getWriter(); Out.println("hello!"); } } 假如要编 译的环境已都已经搭建好。现在用完全正确的命令编译该文件,对于以下陈述正确的是();
第17题:
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?()
第18题:
public class TestA{ public void methodA() throws IOException{ //…… } } public class TestB extends TestA{ public void methodA() throws EOFException{ //…… } } public class TestC extends TestA{ public void methodA() throws Exception{ //…… } } 当编译类TestC的时候,结果是哪项?()
第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?()
第20题:
No code is necessary.
throws Exception
catch ( Exception e )
throws RuntimeException
catch ( TestException e)
第21题:
any class
only the Target class
any class in the test package
any class that extends Target
第22题:
int foo() { /* more code here */ }
void foo() { /* more code here */ }
public void foo() { /* more code here */ }
private void foo() { /* more code here */ }
protected void foo() { /* more code here */ }
第23题:
A user whose role is Admin can perform a PUT.
A user whose role is Admin can perform a GET.
A user whose role is Admin can perform a POST.
A user whose role is Member can perform a PUT.
A user whose role is Member can perform a POST.
A user whose role is Member can perform a GET.
第24题:
Object o = pageContext.getAttribute(foo);
Object o = pageContext.findAttribute(foo);
Object o = pageContext.getAttribute(foo,PageContext.SESSION_SCOPE);
HttpSession s = pageContext.getSession();Object o = s.getAttribute(foo);