E4X (ECMAScript for XML) MCQs

E4X (ECMAScript for XML) MCQs

Our experts have gathered these E4X (ECMAScript for XML) MCQs through research, and we hope that you will be able to see how much knowledge base you have for the subject of E4X (ECMAScript for XML) by answering these 20 multiple-choice questions.
Get started now by scrolling down!

1: Which of the following is not true of the Namespace constructor in E4X?

A.   If the value of the prefixValue parameter is undefined, the prefix is set to undefined.

B.   If the value is a valid XML name, the prefix property is set to a string.

C.   If the value is not a valid XML name, the prefix property is set to undefined.

D.   If a QName object is passed, the uri property is set to the value of the QName object's uri property.

2: State whether true or false:
The QName.prototype.toString() method throws a TypeError exception if its value is not a QName object.

A.   True

B.   False

3: Which of the given options represents the correct length when alert(Emp..*.length()); is applied to the following code?
var Emp = Mark
  
   Linux
   Firefox
   JavaScript
   Python
  

A.   11

B.   5

C.   7

D.   12

4: Which of the following methods is not one of the global methods and properties in E4X?

A.   isXMLName()

B.   isScopeNamespaces()

C.   namespaceDeclarations()

D.   removeNamespaces()

5: Which of the following settings are there in E4x to influence parsing and serialization?
element = Kibology
    for all
;
    elementName = element.name();
    alert(elementName.localName); //
    alert(elementName.uri); //

A.   ignoreComments

B.   ignoreProcessingInstructions

C.   ignoreWhitespace

D.   All of the above

6: Which of the following options would be returned by the code shown in the code snippet:
var f = text alert(f.a[0].hasComplexContent());// p
alert(f.a[1].hasComplexContent());//q
alert(f.a[0].hasSimpleContent());//r
alert(f.a[1].hasSimpleContent());//s

A.   p-false,q-true,r-true,s-false

B.   p-true,q-false,r-false,s-true

C.   p-1,q-0,r-0,s-1

D.   p-0,q-1,r-1

7: What is the value returned when the input parameter type of the XMLList() function in E4x is Number?

A.   TypeError exception

B.   The value is first converted to a string and then converted to an XMLList object.

C.   The value is converted to an XMLList object.

D.   The input value is returned unchanged.

8: What is the default value of the property prettyIndent in E4X?

A.   2

B.   0

C.   4

D.   1

9: Which of the following can be used to create attribute values by placing variables and expressions within them?

A.   []

B.   ()

C.   {}

D.   <>

10: What is the correct way to add a method to an XML.prototype in E4X?

A.   XML.prototype.function::methodName

B.   XML.prototype.function::[methodNameString]

C.   XML.prototype.method::[methodNameString]

11: What will be the output of the following code snippet?
element = Kibology
    for all.
;
    elementName = element.name();
    alert(elementName.localName); //1
    alert(elementName.uri); // 2

A.   1-p,2-http://www.example.org

B.   1-http://www.example.org,2-p

C.   1-http://www.example.org,2-http://www.example.org

D.   1-p,2-p

12: State whether true or false:
An arbitrary xml file can be loaded as an E4X ready object.

A.   True

B.   False

13: What will be the output of the following code snippet?
 var customer =
  888-555-1212
  888-555-2121
  mobile
;
 alert(customer.childIndex());

A.   0

B.   3

C.   NaN

D.   2

14: Which of the following options can be used for adding direct support for XML to JavaScript?

A.   E4X

B.   regex

C.   Generators and Iterators

D.   let

15: Which of the following is not a valid built-in method for XMLList objects in E4X?

A.   attributes()

B.   descendants([name])

C.   hasOwnProperty(propertyName)

D.   append()

16: Which of the following options can be used to delete a child node of an XML object in E4X?

A.   delete xmlobject.child;

B.   delete xmlobject.child[0];

C.   delete xmlobject.@attribute;

D.   All of the above

17: Which of the following is not a reserved keyword in E4X and JavaScript?

A.   volatile

B.   transient

C.   super

D.   version

E.   synchronized

18: Which of the following characters are treated as white space characters?

A.   tab

B.   space

C.   Line feed

D.   enter

19: Consider the following code snippet. Which of the given options would be used in E4X to change the color of the descendant node chair?
var element =
      
      
      
      
      

      

A.   element.chair.color="light brown"

B.   element.chair.@color="light brown"

C.   element..chair.@color="light brown"

D.   element...chair.@color="light brown"

20: Which of the following methods would give the output corresponding to the code snippet?
var test =

  
  example
;

output:


  
  example

A.   alert(test.toString());

B.   alert(test.toXMLString());

C.   alert(test.text());

D.   alert(test.elements());

21: Which of the following are not global methods and properties in E4X?

A.   ignoreComments

B.   ignoreWhiteSpace

C.   setName()

D.   setNamespace()

E.   a and b

F.   c and d

22: Which of the following is the correct syntax for calling the Namespace constructor as a function in E4X?

A.   Namespace()

B.   Namespace(prefixValue)

C.   Namespace(uriValue)

D.   Namespace(prefixValue,uriValue)

23: Which of the following public methods in E4X has the return type XML?

A.   localName()

B.   nodeKind()

C.   parent()

D.   valueOf()

24: What will be the output of the following code snippet?
var xml = ;
xml.appendChild("hello");
Xml.appendChild(" world");
xml.normalize();
alert(xml.children().length());

A.   1

B.   2

C.   3

25: Which of the following options is used to access the attributes in E4X?

A.   @

B.   ::

C.   #

D.   *

26: Which of the following operators is used for inserting XML objects in the context of their parent in E4X?

A.   =

B.   +

C.   +=

D.   =+