Interview Questions and Answers on Markup Languages - XML , JSON

Q1.  What is JSON ?

Ans. JSON is "JavaScript Object Notation", primarily used for client-server or server-server communication. Its a much lighter and readable alternative to XML. JSON is language independent and is easily parse-able in all programming languages.

Q2.  What is the role of JSON.stringify ?

Ans. JSON.stringify() turns an object into a JSON text and stores that JSON text in a string. 

So If we stringfy above notation , it will become

{"name":"xyz","gender":"male";"age":30}

Q3.  Which function is used to convert a JSON text into an object ?

Ans. eval

Q4.  Which data types are supported by JSON ?

Ans. Number
String
Boolean
Array
Object
null

Q5.  What are the benefits of JSON over XML ?

Ans. Lighter and faster than XML as on-the-wire data format
Object Representation - Information is presented in object notations and hence better understandable. Easy to parse and conversion to objects for information consumption.
Support multiple data types - JSON supports string, number, array, boolean whereas XML data are all string.


Q6.  What is XML ?

Ans. XML or eXtensible Markup Language is a markup languages for describing data and its metadata.

Q7.  Difference between SAX and DOM Parser ?

Ans. A DOM (Document Object Model) parser creates a tree structure in memory from an input document whereas A SAX (Simple API for XML) parser does not create any internal structure.

A SAX parser serves the client application always only with pieces of the document at any given time whereas A DOM parser always serves the client application with the entire document no matter how much is actually needed by the client.

A SAX parser, however, is much more space efficient in case of a big input document whereas DOM parser is rich in functionality.

Use a DOM Parser if you need to refer to different document areas before giving back the information. Use SAX is you just need unrelated nuclear information from different areas.

Xerces, Crimson are SAX Parsers whereas XercesDOM, SunDOM, OracleDOM are DOM parsers.

Q8.  What is DTD ?

Ans. DTD or Document Type Definition is a standard agreed upon way of communication between two parties.  Your application can use a standard DTD to verify that data that you receive
from the outside world is valid and can be parsed by your parser.

Q9.  What is XSD ?

Ans. XSD or Xml Schema Definition is an extension of DTD. XSD is more powerful and extensible than DTD

Q10.  What is JAXP ?

Ans. Stands for Java API for XML Processing. This provides a common interface for creating and using SAX, DOM, and XSLT APIs in Java regardless of which vendor’s implementation is actually being used.

Q11.  What is JAXB ?

Ans. Stands for Java API for XML Binding. This standard defines a mechanism for writing out Java objects as XML and for creating Java objects from XML structures. 

Q12.  What is marshalling ?

Ans. Its the process of creating XML structures out of Java Objects.

Q13.  What is unmarshalling ?

Ans. Its the process of creating Java Objects out of XML structures.