469,306 Members | 2,013 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

XML quiz

1) class>
<attributes>
<attr type='static' name='max num' default=0>
<attr type='inst' name='num = 0'\>
</attributes>
<methods>
<meth type='macro' code='x < y & y > z'\>
<meth name='getMax'>
<!CDATA[[
if (num > max num) then max num = num
]]>
</meth>
</methods>
</class>

Referring to the XML data above, how many well-formedness errors does a JAXP processor find?

a) Zero
b) Two
c) Three
d) Five
e) Six


2) What type of data can a SAX parser process?

a) RTF
b) HTML
c) XML
d) Arbitrary plain text
e) SGML

3) <message>
Good
<highlight>
day
</highlight>
earthling.
</message>
org.w3c.dom.Node message = rootnode.getFirstChild();
org.w3c.dom.Node earthling = message.getLastChild();
while (earthling != null)
{
System.out.println(earthling.getNodeValue());
earthling = earthling.getPreviousSibling();
}
Referring to the XML data and DOM code above, where rootnode is a org.w3c.dom.Document object, how many times is the print statement in the while loop executed?

Q4). public class SaxHandler extends org.xml.sax.helpers.DefaultHandler
{
private org.xml.sax.Locator locator;
public void setDocumentLocator(org.xml.sax.Locator locator)
{
this.locator = locator;
}
public void error(org.xml.sax.SAXParseException exception)
{
// Print the source of the error
}
}

Referring to the sample code above, if using a SAX parser, what code do you use in the error method to display the filename, line number, and column number of an error? (sanjay)

a) System.out.println(locator.getPublicId() + ": " +
locator.getLineNumber() + ", " + locator.getColumnNumber());
b) System.out.println(exception.getCause() + ": " +
locator.getLineNumber() + ", " + locator.getColumnNumber());
c) System.out.println(exception.getSystemId() + ": " +
exception.getLineNumber() + ", " + exception.getColumnNumber());
d) org.xml.sax.Locator source = new LocatorImpl();
System.out.println(source.getSystemId() + ": " +
source.getLineNumber() + ", " + source.getColumnNumber());
e) It is not possible to find the name of the file with either the locator or exception variables.
Jul 1 '07 #1
1 3476
Dököll
2,364 Expert 2GB
1)
Expand|Select|Wrap|Line Numbers
  1.  class> 
  2. <attributes> 
  3. <attr type='static' name='max num' default=0> 
  4. <attr type='inst' name='num = 0'\> 
  5. </attributes> 
  6. <methods> 
  7. <meth type='macro' code='x < y & y > z'\> 
  8. <meth name='getMax'> 
  9. <!CDATA[[ 
  10. if (num > max num) then max num = num 
  11. ]]> 
  12. </meth> 
  13. </methods> 
  14. </class> 
  15.  
Referring to the XML data above, how many well-formedness errors does a JAXP processor find?

a) Zero
b) Two
c) Three
d) Five
e) Six


2) What type of data can a SAX parser process?

a) RTF
b) HTML
c) XML
d) Arbitrary plain text
e) SGML

3)
Expand|Select|Wrap|Line Numbers
  1.  <message>
  2. Good
  3. <highlight>
  4. day
  5. </highlight>
  6. earthling.
  7. </message>
  8. org.w3c.dom.Node message = rootnode.getFirstChild();
  9. org.w3c.dom.Node earthling = message.getLastChild();
  10. while (earthling != null)
  11. {
  12.    System.out.println(earthling.getNodeValue());
  13.    earthling = earthling.getPreviousSibling();
  14. }
  15. Referring to the XML data and DOM code above, where rootnode is a org.w3c.dom.Document object, how many times is the print statement in the while loop executed? 
  16.  
  17. Q4). public class SaxHandler extends org.xml.sax.helpers.DefaultHandler 
  18. private org.xml.sax.Locator locator; 
  19. public void setDocumentLocator(org.xml.sax.Locator locator) 
  20. this.locator = locator; 
  21. public void error(org.xml.sax.SAXParseException exception) 
  22. // Print the source of the error 
  23.  
  24.  
Referring to the sample code above, if using a SAX parser, what code do you use in the error method to display the filename, line number, and column number of an error? (sanjay)

a) System.out.println(locator.getPublicId() + ": " +
locator.getLineNumber() + ", " + locator.getColumnNumber());
b) System.out.println(exception.getCause() + ": " +
locator.getLineNumber() + ", " + locator.getColumnNumber());
c) System.out.println(exception.getSystemId() + ": " +
exception.getLineNumber() + ", " + exception.getColumnNumber());
d) org.xml.sax.Locator source = new LocatorImpl();
System.out.println(source.getSystemId() + ": " +
source.getLineNumber() + ", " + source.getColumnNumber());
e)

It is not possible to find the name of the file with either the locator or exception variables.
Greetings and welcome, jigneshluhar!

Thank you for posting this thead.

Have a great night!
Jul 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Sketcher | last post: by
5 posts views Thread by Vandana Rola | last post: by
4 posts views Thread by DAL | last post: by
reply views Thread by philip | last post: by
3 posts views Thread by Raqueeb Hassan | last post: by
nomad
5 posts views Thread by nomad | last post: by
3 posts views Thread by empiresolutions | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.