File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Product and Other Certifications and the fly likes javaranch mock question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "javaranch mock question" Watch "javaranch mock question" New topic

javaranch mock question

jim yin
Ranch Hand

Joined: Aug 15, 2002
Posts: 111
-Consider a system which is memory & speed constraint. The application is to process XML documents, sort the contents and mail them to a higher configuration machine for transformation. Which is the best approach?
a) Use platform native language to process the docuements
b) Use DOM based approach.
c) Using SAX based approach is the best.
d) DOM and SAX must be used in this context.

Answer : b
-There is XML data document which is very large. The application is to extract the very few of its information from document. The memory & speed may be a constraint. Which is the most likely method to be implemented?
a) Extract the information using SAX API, event based methods.
b) To extract the information using DOM API.
c) To extract the necessary information and process using XSLT.
d) To use schema based approach.
Answers : b
If memory is a concern, why don't we use SAX? DOM will load the whole document into memory, right?
[ September 10, 2002: Message edited by: jim yin ]
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
I think that the following clippings matter here -
"application has to sort the contents"
"application has to extract part of the document"
Hence if we are to do something with the content, the only way we can do it is using DOM. Sax just walks thru the document and i think it gets extremely painful(too many criterion to take into account w.r.t the xml tree) if we are to extract a part of the contents in the process.
My only concern here is why not XSLT to extract part of the document, which i guess is pretty fast than the DOM based approach; I guess we can run a xsl-stylesheet on the xml instance document from within our application, but again we have to hold the data in buffer in order to play with it and hence again DOM.
Vasudha Deepak
Ranch Hand

Joined: Mar 15, 2002
Posts: 86
Dom is the best approach in both the cases.
In first case,DOM is used since you need to sort the contents and in the second one you need to extract few information.
SAX does not provide random search.So if you need to extract very few data ,SAX will follow a sequential order in searching for the required content,whereas with DOM you can directly search the needed information.
As far as XSLT is concerned,the XSLT processors hold all data in memory while transformation is taking place and eventually the tree structure may be almost 10 times the data size.
Since the data file specified in the quesion is large,so finally DOM would be the best approach.

Hope this help.

IBM Certified Developer -XML and Related Technologies(141)<br />SCJP2 SCWCD
Ronak Patel
Ranch Hand

Joined: Aug 14, 2002
Posts: 31
DOM is best in first case but in second case
answer may be SAX.
Because in second case application has to extract very few information and memory & speed may be a constrain."SAX or DOM" depends on which type of data u want to extract from document.
<user name="Ronak">
<user name="David">
<address>New york</address>
<user name="Mahesh">

SAX is best for following searching like
-> find user name and its age where
username like ="Ro%"
-> average age of all user
-> list all user and their address
DOM is best for following searching like
-> list all username whose age is belove than
average age
(for this u have to first calculate average
and than u can take decision)

May be helpful.
Jeff X Williams

Joined: Sep 28, 2001
Posts: 29
These are poorly written questions because they give conflicting requirements and wrong answers. The real exam is not quite this bad. If the question states that performance and/or memory are a big concern then the answer is almost certainly going to be SAX.
The author of the question (I guess) would say that performance and memory are secondary to the other requirement, but I would say that if you don't have enough memory to load the document using DOM, then nothing else matters. You CAN sort using SAX (might be hard, but possible) and you CAN search for a few elements using SAX (may actually be more efficient than DOM anyway), but if you don't have enough memory to load the document using DOM then you CAN'T sort and you CAN'T search for a few items.
So, the bottom line is the answers given to these sample questions are WRONG! There really aren't any good sample exams that don't contain bad questions like these and are similar to the IBM style of questions. The closest is the IBM sample XML exam.
I agree. Here's the link:
subject: javaranch mock question
It's not a secret anymore!