多选题在J2EE中,使用()选项中的代码,可以生成如下XML文档:      Tony BlairAElement people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); Element name = doc.createElement(NAME); name.appendChild(doc.createTextNode(Tony Blair)); people.appendChild(person)

题目
多选题
在J2EE中,使用()选项中的代码,可以生成如下XML文档:      Tony Blair
A

Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); Element name = doc.createElement(NAME); name.appendChild(doc.createTextNode(Tony Blair)); people.appendChild(person); person.appendChild(name); doc.appendChild(people);

B

Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); people.appendChild(person); Element name = doc.createElement(NAME); name.appendChild(doc.createTextNode(Tony Blair)); person.appendChild(name); doc.appendChild(people);

C

Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); people.appendChild(person); Element name = doc.createElement(NAME); name.appendText(doc.createTextNode(Tony Blair)); person.appendChild(name); doc.appendChild(people);

D

Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON);Element name = doc.createElement(NAME); name.createTextNode(Tony Blair); people.appendChild(person); person.appendChild(name); doc.appendChild(people);


相似考题
更多“多选题在J2EE中,使用()选项中的代码,可以生成如下XML文档:      Tony BlairAElement people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); Element name = doc.createElement(NAME); name.appendChild(doc.createTextNode(Tony Blair)); people.appendChild(person)”相关问题
  • 第1题:

    class Person{ String name,department; int age; public Person(Stringn){name=n;} public Person(String n, int a){name=n;age=a;} publicPerson(String n,String d,int a){ doing the same as two argumentsversion of constructer including assignment name=n,age=a } } 下列哪一个选项可以添加到“doing the same....”处?()

    APerson(n,a)

    Bthis(Person(n,a))

    Cthis(n,a)

    Dthis(name,age


    参考答案C

  • 第2题:

    阅读下面代码 abstract class Person { public Person(String n) { name=n; } public______String getDescription(); public String getName() { return name; } private String name; } 在下画线处应填入的修饰符是

    A.static

    B.abstract

    C.protected

    D.final


    正确答案:B

  • 第3题:

    给出下面不完整的类代码,则横线处的语句应该为( )。 class Person { String name,department; int age; public Person (Strings) {name=s;} public Person (String s,int

    A.{name=s;age=a;} public Person (String n,String d,intA){ __________ department=d; } }A)Person (n,A);

    B.this (Person(n,A));

    C.this(n,A);

    D.this(name,age);


    正确答案:C
    解析:本题主要考查在同一个类的不同构造方法中调用该类的其他构造方法需要使用 this(…)的形式,而且必须是在构造方法的第一行调用。这个和普通方法重载调用的方式不同,普通方法可以直接使用方法名加参数来调用,而且调用位置没有限制,因此选项A是不行的,选项B的语法就是错误的,选项D的错误在于在父类型的构造方法被调用前不能引用类的成员。构造方法是一个类对象实例化的开始,因此在构造方法中不能将成员作为参数引用。

  • 第4题:

    Person p = new Person(“张三”,23);这条语句会调用下列哪个构造方法给属性进行初始化()

    A.public Person(){}

    B.public Person(String name,int age) { this.name = name; this.age = age; }

    C.public Person(int age,String name) { this.age = age; this.name = name; }

    D.public Person(String name) { this.name = name; }


    答案:B
    解析:创建对象时会找到匹配的构造方法给属性进行初始化,由于Person p = new Person(“张三”,23);这条语句中有两个参数,而且第1个参数是String类型的,第2个参数是int类型的,因此会调用B选项中的构造方法。

  • 第5题:

    有如下XML代码段: <element>text</element> 可以通过哪些方法获得标记<element>中的数据“text”?


    正确答案: 第一种方法:获得Element节点“element”,通过Node接口的getTextContent()方法获得“element”节点的文本数据。
    第二种方法:获得Element节点“element”的子节点,即Text类型节点,通过Text节点的getWholeText()方法获得文本数据。

  • 第6题:

    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

  • 第7题:

    在Person的一个派生类Employee里调用Person类的构造函数正确方式为()。

    • A、base.Person(name,age)
    • B、base(name,age)
    • C、Person(name,age)
    • D、this(name,age)

    正确答案:B

  • 第8题:

    在J2EE中,假设sample.xml文档有一个元素是,它有个子元素是。我们已经获得了Document对象doc,取出第一个的第一个资源的值的代码是()。 

    • A、((Element)doc.getElementsByTagName(“PERSON”).item(0)).getNodeValue()
    • B、((Element)doc.getElementsByTagName(“PERSON”).item(0)).getElementsByTagName(“NAME”).item(0).getFirstChild().getNodeValue()
    • C、((Element)doc.getElementsByTagName(“PERSON”).item(0)).getElementsByTagName(“NAME”).item(0).getNodeValue()
    • D、((Element)doc.getElementsByTagName(“PERSON”).item(0)). item(0).getNodeValue()

    正确答案:B

  • 第9题:

    public class Person {  private name;  public Person(String name) {  this.name = name;  }  public boolean equals(Object o) {  if( !o instanceof Person ) return false;  Person p = (Person) o;  return p.name.equals(this.name);  }  }  Which is true?() 

    • A、 Compilation fails because the hashCode method is not overridden.
    • B、 A HashSet could contain multiple Person objects with the same name.
    • C、 All Person objects will have the same hash code because the hashCode method is not overridden.
    • D、 If a HashSet contains more than one Person object with name=”Fred”, then removing another person, also with name=”Fred”, will remove them all.

    正确答案:B

  • 第10题:

    单选题
    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.


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

  • 第11题:

    单选题
    在Person的一个派生类Employee里调用Person类的构造函数正确方式为()。
    A

    base.Person(name,age)

    B

    base(name,age)

    C

    Person(name,age)

    D

    this(name,age)


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

  • 第12题:

    单选题
    在J2EE中,假设sample.xml文档有一个元素是,它有个子元素是。我们已经获得了Document对象doc,取出第一个的第一个子元素的值的代码是()。
    A

    ((Element)doc.getElementsByTagName(PERSON).item(0)).getNodeValue();

    B

    ((Element)doc.getElementsByTagName(PERSON).item(0)).getElementsByTagName(NAME).item(0).getFirstChild().getNodeValue();

    C

    ((Element)doc.getElementsByTagName(PERSON).item(0)).getElementsByTagName(NAME).item(0).getNodeValue();

    D

    ((Element)doc.getElementsByTagName(PERSON).item(0)).item(0).getNodeValue();


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

  • 第13题:

    给出下列的不完整的类代码,则哪个语句可以被加到横线处? ( ) class Person{ String name,department; int age; public Person(String n){name=n;} public Person(String n,int s){name=n; age=a;} public Person(String n,String d,int a){ department=d;______ } }

    A.Person(n,a);

    B.this(Person(n,a));

    C.this(n,s);

    D.this(name,age);


    正确答案:C

  • 第14题:

    给出下列的不完整的类代码,则下列的( )语句可以加到横线处。 class Person{ String name,department; int age public Person(String n){name=n;} public Person(String n,int a){name=n;age=a;} pubilc Person(String n,String d,int a) { _______________ department=d; } }

    A.Person(n,a);

    B.this(Person(n,a));

    C.this(n,a);

    D.this(name,age);


    正确答案:C

  • 第15题:

    为使下列代码正常运行,应该在下画线处填入的选项是( )。 abstract class person{ public Person(String n){ name=n: } Public String getDescription; public String getName{ return name; } private string name; }

    A.static

    B.private

    C.abstract

    D.final


    正确答案:C
    C。【解析】抽象类中的抽象方法可以只声明,定义延迟到其子类。

  • 第16题:

    在J2EE中,使用()选项中的代码,可以生成如下XML文档:    Tony Blair   

    • A、Element people = doc.createElement("PEOPLE");  Element person = doc.createElement("PERSON"); Element name = doc.createElement("NAME"); name.appendChild(doc.createTextNode("Tony Blair")); people.appendChild(person); person.appendChild(name); doc.appendChild(people);
    • B、Element people = doc.createElement("PEOPLE");  Element person = doc.createElement("PERSON"); people.appendChild(person); Element name = doc.createElement("NAME"); name.appendChild(doc.createTextNode("Tony Blair")); person.appendChild(name); doc.appendChild(people);
    • C、Element people = doc.createElement("PEOPLE");  Element person = doc.createElement("PERSON"); people.appendChild(person); Element name = doc.createElement("NAME"); name.appendText(doc.createTextNode("Tony Blair")); person.appendChild(name); doc.appendChild(people);
    • D、Element people = doc.createElement("PEOPLE");  Element person = doc.createElement("PERSON");Element name = doc.createElement("NAME"); name.createTextNode("Tony Blair"); people.appendChild(person); person.appendChild(name); doc.appendChild(people);

    正确答案:A,B

  • 第17题:

    public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age && name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?() 

    • A、 return super.hashCode();
    • B、 return name.hashCode() + age * 7;
    • C、 return name.hashCode() + comment.hashCode() /2;
    • D、 return name.hashCode() + comment.hashCode() / 2 - age * 3;

    正确答案:B

  • 第18题:

    下面的文件正确吗?为什么?用IE和本章中的解析器验证你的结论。 mes.dtd <!ELEMENT message ANY> <!ELEMENT persion (name,age?,lxfs)> <!ELEMENT lxfs (#PCDATA,tel|email)*> <!ELEMENT name (first,last)> <!ATTLIST name sex (male|female) "male"> <!ELEMENT first %pc; > <!ELEMENT last %pc;> <!ELEMENT age %pc;> <!ELEMENT tel %pc;> <!ELEMENT email %pc;> <!ENTITY % pc “(#PCDATA)”> <!ELEMENT emergency EMPTY> <!ATTLIST emergency fire CDATA #FIXED "119" police CDATA #FIXED "110" hospital CDATA #FIXED "120" > mes.xml <?xml version="1.0" encoding="gb2312"?> <!DOCTYPE SYSTEM "mes.dtd"> <message> <persion> <name sex="男"> <first>li</first> <last>xiao</last> </name> <age>25</age> <lxfs> <tel>123456</tel> </lxfs> </persion> <persion> <name> <first>wang</first> <last>xiao</last> </name> <lxfs></lxfs> </persion> <emergency fire="120" police="110" /> </message>


    正确答案: 不正确。有5处错误,“<!ELEMENT lxfs (#PCDATA,tel|email)*>”句“#PCDATA”与“tel”之间应该用“|”,或去掉“#PCDATA”;参数实体应先声明后使用;文档类型声明缺少根元素;“name”的“sex”属性取值错误;“emergency”的“fire”属性取值错误。正确的文件:mes.dtd <!ELEMENT message ANY>
    <!ELEMENT persion (name,age?,lxfs)>
    <!ELEMENT lxfs (#PCDATA|tel|email)*>
    <!ELEMENT name (first,last)>
    <!ATTLIST name sex (male|female) "male">
    <!ENTITY % pc "(#PCDATA)">
    <!ELEMENT first %pc; >
    <!ELEMENT last %pc;>
    <!ELEMENT age %pc;>
    <!ELEMENT tel %pc;>
    <!ELEMENT email %pc;>
    <!ELEMENT emergency EMPTY>
    <!ATTLIST emergency
    fire CDATA #FIXED "119"
    police CDATA #FIXED "110"
    hospital CDATA #FIXED "120"

    mes.xml
    <?xml version="1.0" encoding="gb2312"?>
    <!DOCTYPE message SYSTEM "mes.dtd">
    <message>
    <persion>
    <name sex="male">
    <first>li</first>
    <last>xiao</last>
    </name>
    <age>25</age>
    <lxfs>
    <tel>123456</tel>
    </lxfs>
    </persion>
    <persion>
    <name>
    <first>wang</first>
    <last>xiao</last>
    </name>
    <lxfs></lxfs>
    </persion>
    <emergency fire="119" police="110" />
    </message>

  • 第19题:

    在J2EE中,假设sample.xml文档有一个元素是,它有个子元素是。我们已经获得了Document对象doc,取出第一个的第一个子元素的值的代码是()。 

    • A、((Element).doc.getElementsByTagName(“PERSON”).item(0)).getNodeValue;
    • B、 ((Element).doc.getElementsByTagName(“PERSON”).item(0)).getFristChild().getNodeValue();
    • C、 ((Element).doc.getElementsByTagName(“PERSON”).item(0)).getElementsByTagName(“NAME”).item(0).getNodeValue();
    • D、 ((Element).doc.getElementsByTagName(“PERSON”).item(0)).item(0).getNodeValue();

    正确答案:C

  • 第20题:

    Given the uncompleted code of a class:     class Person {  String name, department;     int age;  public Person(String n){  name = n; }  public Person(String n, int a){  name = n;  age = a;  }  public Person(String n, String d, int a) {  // doing the same as two arguments version of constructor     // including assignment name=n,age=a    department = d;     }     }  Which expression can be added at the "doing the same as..." part of the constructor?() 

    • A、 Person(n,a);
    • B、 this(Person(n,a));
    • C、 this(n,a);
    • D、 this(name,age);

    正确答案:C

  • 第21题:

    单选题
    在J2EE中,假设sample.xml文档有一个元素是,它有个子元素是。我们已经获得了Document对象doc,取出第一个的第一个子元素的值的代码是()。
    A

    ((Element).doc.getElementsByTagName(“PERSON”).item(0)).getNodeValue;

    B

     ((Element).doc.getElementsByTagName(“PERSON”).item(0)).getFristChild().getNodeValue();

    C

     ((Element).doc.getElementsByTagName(“PERSON”).item(0)).getElementsByTagName(“NAME”).item(0).getNodeValue();

    D

     ((Element).doc.getElementsByTagName(“PERSON”).item(0)).item(0).getNodeValue();


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

  • 第22题:

    单选题
    public class Person {  private name;  public Person(String name) {  this.name = name;  }  public boolean equals(Object o) {  if( !o instanceof Person ) return false;  Person p = (Person) o;  return p.name.equals(this.name);  }  }  Which is true?()
    A

     Compilation fails because the hashCode method is not overridden.

    B

     A HashSet could contain multiple Person objects with the same name.

    C

     All Person objects will have the same hash code because the hashCode method is not overridden.

    D

     If a HashSet contains more than one Person object with name=”Fred”, then removing another person, also with name=”Fred”, will remove them all.


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

  • 第23题:

    多选题
    在J2EE中,使用()选项中的代码,可以生成如下XML文档:      Tony Blair
    A

    Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); Element name = doc.createElement(NAME); name.appendChild(doc.createTextNode(Tony Blair)); people.appendChild(person); person.appendChild(name); doc.appendChild(people);

    B

    Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); people.appendChild(person); Element name = doc.createElement(NAME); name.appendChild(doc.createTextNode(Tony Blair)); person.appendChild(name); doc.appendChild(people);

    C

    Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON); people.appendChild(person); Element name = doc.createElement(NAME); name.appendText(doc.createTextNode(Tony Blair)); person.appendChild(name); doc.appendChild(people);

    D

    Element people = doc.createElement(PEOPLE);  Element person = doc.createElement(PERSON);Element name = doc.createElement(NAME); name.createTextNode(Tony Blair); people.appendChild(person); person.appendChild(name); doc.appendChild(people);


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

  • 第24题:

    单选题
    public class Person {  private String name, comment;  private int age;  public Person(String n, int a, String c) {  name = n; age = a; comment = c;  }  public boolean equals(Object o) {  if(! (o instanceof Person)) return false;  Person p = (Person)o;  return age == p.age && name.equals(p.name);  }  }  What is the appropriate definition of the hashCode method in class Person?()
    A

     return super.hashCode();

    B

     return name.hashCode() + age * 7;

    C

     return name.hashCode() + comment.hashCode() /2;

    D

     return name.hashCode() + comment.hashCode() / 2 - age * 3;


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