SCWCD(310-083)

单选题Your IT department is building a lightweight Front Controller servlet that invokes an application logic objectwith the interface: public interface ApplicationController {public String invoke(HttpServletRequest request)} The return value of this method 

题目
单选题
Your IT department is building a lightweight Front Controller servlet that invokes an application logic objectwith the interface: public interface ApplicationController {public String invoke(HttpServletRequest request)} The return value of this method indicates a symbolic name of the next view. From this name, the FrontController servlet looks up the JSP URL in a configuration table. This URL might be an absolute path or apath relative to the current request. Next, the Front Controller servlet must send the request to this JSP togenerate the view. Assume that the servlet variable request is assigned the current HttpServletRequestobject and the variable context is assigned the webapp’s ServletContext. Which code snippet of the FrontController servlet accomplishes this goal?()
A

Dispatcher view=context.getDispatcher(viewURL);view.forward Request(request, response);

B

Dispatcher view=request.getDispatcher(viewURL);view.forward Request(request, response);

C

RequestDispatcher view. =context.getRequestDispatcher(viewURL);view.forward(request,response);

D

RequestDispatcher view=request.getRequestDispatcher(viewURL);view.forward(request, response);

参考答案和解析
正确答案: D
解析: 暂无解析
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

Servlet的基本架构

public class ServletName extends HttpServlet {

public void doPost(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws

ServletException, IOException {

}

}

1、用String的方法将数据类型转换为String。


正确答案:

 

1、String.valueOf(1.23)

第2题:

public class Employee{   private String name;   public Employee(String name){   this.name = name;  }   public String getName(){   return name;  }  }   public class Manager extends Employee{   private String department;   public Manager(String name,String department){   this.department = department;   super(name); (应于上一行掉位置)   System.out.println(getName());  }  }   Super的位置是否在方法的首行   执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?()

  • A、 smith
  • B、 null
  • C、 SALES
  • D、 编译错误

正确答案:D

第3题:

A Windows Communication Foundation (WCF) solution uses the following contracts. (Line numbers are included for reference only.)

01 [ServiceContract(CallbackContract=typeof(INameService))]

02 public interface IGreetingService

03 {

04 [OperationContract]

05 string GetMessage();

06 }

07 [ServiceContract]

08 public interface INameService

09 {

10 [OperationContract]

11 string GetName();

12 }

The code that implements the IGreetingService interface is as follows:

20 public class GreetingService : IGreetingService

21{

22 public string GetMessage()

23 {

24 INameService clientChannel = OperationContext.Current.GetCallbackChannel();

25 string clientName = clientChannel.GetName();

26 return String.Format("Hello {0}", clientName);

27 }

28 }

The service is self-hosted. The hosting code is as follows:

30 ServiceHost host = new ServiceHost(typeof(GreetingService));

31 NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

32 host.AddServiceEndpoint("MyApplication.IGreetingService", binding, "net.tcp//localhost:12345");

33 host.Open();

The code that implements the lNameService interface is as follows:

40 class NameService : INameService

41 {

42 string name;

43 public NameService(string name)

44 {

45 this.name = name;

46 }

47 public string GetName()

48 {

49 return name;

50 }

51 }

Currently, this code fails at runtime, and an InvalidOperationException is thrown at line 25. You need to correct the code so that the call from the service back to the client completes successfully. What are two possible ways to achieve this goal? (Each correct answer presents a complete solution. Choose two.)()


参考答案:C, D

第4题:

public class Employee{       private String name;  public Employee(String name){           this.name = name;      }  public String getName(){         return name;      } }  public class Manager extends Employee{       private String department;  public Manager(String name,String department){          this.department = department;          super(name);  System.out.println(getName());      }  }  执行语句new Manager(“smith”,”SALES”)后程序的输出是哪项?() 

  • A、 smith
  • B、 null
  • C、 SALES
  • D、 编译错误

正确答案:D

第5题:

Which three demonstrate an “is a” relationship?() 

  • A、 public class X {  }     public class Y extends X { }
  • B、 public interface Shape { }     public interface Rectangle extends Shape{ }
  • C、 public interface Color { }     public class Shape { private Color color; }
  • D、 public interface Species { }     public class Animal { private Species species; }
  • E、 public class Person { }    public class Employee {      public Employee(Person person) { }
  • F、 interface Component { }     class Container implements Component {   private Component[] children; }

正确答案:A,B,F

第6题:

public interface A {  String DEFAULT_GREETING = “Hello World”;  public void method1();  }  A programmer wants to create an interface called B that has A as its parent. Which interface declaration is correct?() 

  • A、 public interface B extends A {}
  • B、 public interface B implements A {}
  • C、 public interface B instanceOf A {}
  • D、 public interface B inheritsFrom A {}

正确答案:A

第7题:

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

第8题:

interface Playable {

void play();

}

interface Bounceable {

void play();

}

interface Rollable extends Playable, Bounceable {

Ball ball = new Ball("PingPang");

}

class Ball implements Rollable {

private String name;

public String getName() {

return name;

}

public Ball(String name) {

this.name = name;

}

public void play() {

ball = new Ball("Football");

System.out.println(ball.getName());

}

}

这个错误不容易发现。


正确答案:

 

错。"interface Rollable extends Playable, Bounceable"没有问题。interface 可继承多个

interfaces,所以这里没错。问题出在interface Rollable 里的"Ball ball = new Ball("PingPang");"。

任何在interface 里声明的interface variable (接口变量,也可称成员变量),默认为public static

final。也就是说"Ball ball = new Ball("PingPang");"实际上是"public static final Ball ball = new

Ball("PingPang");"。在Ball 类的Play()方法中,"ball = new Ball("Football");"改变了ball 的

reference,而这里的ball 来自Rollable interface,Rollable interface 里的ball 是public static final

的,final 的object 是不能被改变reference 的。因此编译器将在"ball = new Ball("Football");"

这里显示有错。

第9题:

Your IT department is building a lightweight Front Controller servlet that invokes an application logic objectwith the interface: public interface ApplicationController {public String invoke(HttpServletRequest request)} The return value of this method indicates a symbolic name of the next view. From this name, the FrontController servlet looks up the JSP URL in a configuration table. This URL might be an absolute path or apath relative to the current request. Next, the Front Controller servlet must send the request to this JSP togenerate the view. Assume that the servlet variable request is assigned the current HttpServletRequestobject and the variable context is assigned the webapp’s ServletContext. Which code snippet of the FrontController servlet accomplishes this goal?()

  • A、Dispatcher view=context.getDispatcher(viewURL);view.forward Request(request, response);
  • B、Dispatcher view=request.getDispatcher(viewURL);view.forward Request(request, response);
  • C、RequestDispatcher view. =context.getRequestDispatcher(viewURL);view.forward(request,response);
  • D、RequestDispatcher view=request.getRequestDispatcher(viewURL);view.forward(request, response);

正确答案:D

第10题:

Which is a method of the MouseMotionListener interface?()

  • A、 Public void mouseMoved(MouseEvent)
  • B、 Public boolean mouseMoved(MouseEvent)
  • C、 Public void mouseMoved(MouseMotionEvent)
  • D、 Public boolean MouseMoved(MouseMotionEvent)
  • E、 Public boolean mouseMoved(MouseMotionEvent)

正确答案:A

更多相关问题