SCDCD(310-081)

单选题Which HttpSession method stores an object in a session?()Aput(String name. Object value)Bset(String name. Object value)CsetAttribute(String name. Object value)DputAttribute(String name. Object value)EaddAttribute(String name. Object value)

题目
单选题
Which HttpSession method stores an object in a session?()
A

 put(String name. Object value)

B

 set(String name. Object value)

C

 setAttribute(String name. Object value)

D

 putAttribute(String name. Object value)

E

 addAttribute(String name. Object value)

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

在下列选项中,正确创建并实现写入cookie的语句分别是()。 

  • A、 Cookie cookie = new Cookie( String key, Object value );
  • B、 Cookie cookie = new Cookie();
  • C、 response.add(cookie );
  • D、 response.addCookie(cookie);

正确答案:A,D

第2题:

Which statements concerning the value of a member variable are true, when no explicit assignments have been made?()  

  • A、The value of an int is undetermined.
  • B、The value of all numeric types is zero.
  • C、The compiler may issue an error if the variable is used before it is initialized.
  • D、The value of a String variable is "" (empty string).
  • E、The value of all object variables is null.

正确答案:B,E

第3题:

Given:What is the result?()

A.Compilation fails.

B.exception is thrown at runtime.

C.The attribute id in the ItemTest object remains unchanged.

D.The attribute id in the ItemTest object is modified to the new value.

E.A new ItemTest object is created with the preferred value in the id attribute.


参考答案:A

第4题:

String s=new String("xyz");创建了几个String Object?


正确答案: 两个或一个,”xyz”对应一个对象,这个对象放在字符串常量缓冲区,常量”xyz”不管出现多少遍,都是缓冲区中的那一个。New String每写一遍,就创建一个新的对象,它一句那个常量”xyz”对象的内容来创建出一个新String对象。如果以前就用过’xyz’,这句代表就不会创建”xyz”自己了,直接从缓冲区拿。

第5题:

Given an HttpServletRequest request: 22.String id = request.getParameter("jsessionid"); 23.// insert code here 24.String name = (String) session.getAttribute("name"); Which three can be placed at line 23 to retrieve anexisting HttpSession object?()

  • A、HttpSession session = request.getSession();
  • B、HttpSession session = request.getSession(id);
  • C、HttpSession session = request.getSession(true);
  • D、HttpSession session = request.getSession(false);
  • E、HttpSession session = request.getSession("jsessionid");

正确答案:A,C,D

第6题:

public class ItemTest {  private final mt id;  public ItemTest(int id) { this.id = id; }  public void updateId(int newId) { id = newId; }  public static void main(String[] args) {  ItemTest fa = new ItemTest(42);  fa.updateId(69);  System.out.println(fa.id);  }  }  What is the result?() 

  • A、 Compilation fails.
  • B、 An exception is thrown at runtime.
  • C、 The attribute id in the Item object remains unchanged.
  • D、 The attribute id in the Item object is modified to the new value.
  • E、 A new Item object is created with the preferred value in the id attribute.

正确答案:A

第7题:

public class Person {  private name;  public Person(String name) {  this.name = name;  }  public int hashCode() {  return 420;  }  }  Which is true?() 

  • A、 The time to find the value from HashMap with a Person key depends on the size of the map.
  • B、 Deleting a Person key from a HashMap will delete all map entries for all keys of typePerson.
  • C、 Inserting a second Person object into a HashSet will cause the first Person object to beremoved as a duplicate.
  • D、 The time to determine whether a Person object is contained in a HashSet is constant and does NOT depend on the size of the map.

正确答案:A

第8题:

以下程序的运行结果为:public class My{int value;public static void main(String args[]) {My x=new My();if (x==null)System.out.println("No Object");elseSystem.out.println(x.value);}}

A. 0

B. 1

C. No Object

D. 编译错误

E. null


正确答案:A

第9题:

在j2ee中,以下是firevetoablechange方法的正确的原型的是() 

  • A、public void fireVetoableChange(Object  oldValue,Object newValue)
  • B、 public void fireVetoableChange(String  propertyName,Object newValue)
  • C、 public void fireVetoableChange(String  propertyName, Object  oldValue ,Object newValue)throws PropertyVetoException
  • D、 public void fireVetoableChange(String  propertyName, Object  oldValue ,Object newValue)

正确答案:C

第10题:

在J2EE中,以下是firePropertyChange的原型,正确的是()。 

  • A、public void firePropertyChange(PropertyChangeListener l,String oldValue, String newValue)
  • B、public void firePropertyChange(String propertyName, Object oldValue, Object newValue)
  • C、public void firePropertyChange(PropertyChangeSupport changes)
  • D、public void firePropertyChange(Object oldValue, Object newValue)

正确答案:B

更多相关问题