JSON Test

1. JSON name/value pair is written as
Answers:
• "name" : "value"
• name' : 'value'
• name = "value"
• name = 'value'
2. Does whitespace matter in JSON?
Answers:
• No, it will be stripped out.
• Yes, only within strings.
• Yes, only outside of strings.
• Yes, both inside and outside of strings
3. In this example, what would the TYPE of employee.hireDate be? { "employee" : {      "type" : "Director",      "functions" : ['sales', 'marketing'],      "hireDate" : "March 8, 2011"    } }
Answers:
• String
• Date
• March 8, 2011
• Number
4. Which statement about the replacer parameter in JSON.stringify() is true?
Answers:
• All three statements are true
• If an array, specifies the names of the properties in the object to include in the resulting JSON string
• If null or omitted, all properties of the object are included in the resulting JSON string
• If a function, transforms values and properties encountered while stringifying
5. Can you use a double quote inside a JSON string?
Answers:
• Yes, if it is escaped like ( \" )
• No, you should use single quotes
• Yes, you can use it without any special treatment
• Yes, if you use the ascii code.
6. Given this JSON example: {     "Employee":     {         "Name": "Amy",         "Age": 25     } };  What is the type of Employee.Age ?
Answers:
• Array
• Object
• String
• Number
7. Which answer represents the following order of TYPES? Object, String, Boolean, Number
Answers:
• "{ }", "a string", "false", "0"
• [ ], 0, "true", "0"
• { }, "0", false, 0
• { }, hello, "false", "0"
8. In the below notation, Employee is of type  {     "Employee":     {         "Name": "Amy",         "Age": 25     } }
Answers:
• Object
• Not a valid JSON string
• Array
• Class
9. Which of the following is not a JSON type?
Answers:
• string
• Object
• date
• Array
10. What is the file extension of JSON?
Answers:
• .jn
• .jsn
• .js
• .json
11. In modern websites what is the common usage for JSON?
Answers:
• To store information locally.
• To send and receive bits of data.
• To store information remotely.
12. In the below notation, Employee is of type  {     "Employee":     [         "Amy",         "Bob",         "John"     ] }
Answers:
• Class
• Object
• Array
• Not a valid JSON string
13. What does JSON stand for?
Answers:
• JavaScript Object Notation
• JavaScript Objective Notation
• JavaScript Orientated Nomenclature
• JavaScript Object Nomenclature
14. Which of these is proper a JSON array?
Answers:
• { 'letters' : {"a", "b", "c" } }
• { "letters" : [ "a", "b", "c" ] }
• { "letters" : [ "a", "b", "c"; ] }
• { "letters" : [ a, b, c ] }
15. In this example, what is the TYPE of employee? { "employee" : {      "type" : "Director",      "functions" : ['sales', 'marketing']    } }
Answers:
• String
• type
• Object
• Director
16. Which of these is a benefit JSON has over XML?
Answers:
• JSON can be written poorly and still be parsed
• JSON is more forgiving of poor formatting
• JSON has less markup requirements and therefore is lighter than XML
• JSON does not need to be stored in a file to be sent remotely
17. In this example, what is the TYPE of employee.functions? { "employee" : {      "type" : "Director",      "functions" : ['sales', 'marketing']    } }
Answers:
• Sales, Marketing
• Object
• Array
• String
18. JSON elements are separated by
Answers:
• comma
• line break
• semi-colon
• white space
19. Which statement about the reviver parameter in JSON.parse() is true?
Answers:
• Each value will be replaced by the result of the reviver function
• A function that will be called for every key and value at every level of the final result
• Used to reform generic objects into instances of pseudo-classes
• All three statements are true
20. What keywords are reserved in JSON and cannot be used as keys?
Answers:
• Value
• Key
• Object
• There are none.
21. What kind of format is JSON, and what does the acronym mean?
Answers:
• A lightweight database framework. JavaScript Object Notation.
• A lightweight data-interchange format. JavaScript Object Notation.
• A lightweight data-interchange format. Java Objective Notion.
• A lightweight data-encoding framework. Java Omnipresent Notation.
22. Which of these is correct about the JSON standard?
Answers:
• It is an open standard
• It is privately developed
• It requires a license to use
23. Which statement about the toJSON method is true?
Answers:
• All three statements are true
• It customizes JSON stringification behavior
• It is internally called by JSON.stringify()
• It allows an object to determine its own JSON representation
24. Which of the following is a valid JSON string?
Answers:
• { "meals" : [ "breakfast" , "lunch" , "dinner" ] }
• { "meals" : { "breakfast" , "lunch" , "dinner" } }
• [ {"meals" : { "breakfast" , "lunch" , "dinner" } } ]
• [ "meals" : { "breakfast" , "lunch" , "dinner" } ]
25. What function will convert a JavaScript object to a JSON string?
Answers:
• JSON.stringify()
• JSON.text()
• JSON.serialize()
• JSON.toString()
26. Which of the following code will throw an error?
Answers:
• JSON.parse(undefined);
• JSON.parse('[]');
• JSON.parse(null);
• JSON.parse('{}');
27. Which of the following code will return a valid JSON object?
Answers:
• JSON.parse('{"FirstName": "John", "LastName":"Doe"}');
• JSON.parse("({'FirstName': 'John', 'LastName':'Doe'})");
• JSON.parse('({"FirstName": "John", "LastName":"Doe"})');
• JSON.parse("{'FirstName': 'John', 'LastName':'Doe'}");
28. Which of these data interchange formats has seen a decline in usage in favor of JSON?
Answers:
• XML
• ASCII
• SQL
• Plain-text
29. True or false? The order of elements in JSON arrays is always preserved.
Answers:
• False
• True
30. Which is true about JSON namespacing?
Answers:
• JSON namespaces can be accessed after parsing data.
• JSON namespaces can be accessed immediately after receiving data.
• JSON doesn't have namespaces. Though every object is inherently a namespace.
31. True or false? A disadvantage of JSON is that it requires the use of JavaScript.
Answers:
• False, JavaScript must be available although it is not necessary to use.
• True, though JavaScript is readily available in today's browsers.
• False, JSON is language independent.
• True, though all browsers have JavaScript enabled.
32. Which of these is supported as a JSON Value type?
Answers:
• NaN
• Undefined
• Infiniti
• Null
33. What is the MIME type of JSON?
Answers:
• application/x-json
• application/javascript
• application/json
• text/json
34. In this example, what would the VALUE of employee.functions[1] be? { "employee" : {      "type" : "Director",      "functions" : ['sales', 'marketing']    } }
Answers:
• undefined
• null
• sales
• marketing
35. What is the value of obj in the following code?  var obj = JSON.parse('{"fruit": "Apple"}',                      function(k, v)                      {                          if (v == "Apple")                              return "Orange"                          else                               return v;                      });
Answers:
• { "fruit" : "Apple"}
• { "fruit" : "Orange"}
• {"Apple"}
• {"Orange"}
36. In this example, what is the VALUE of employee.type? { "employee" : {      "type" : "Director",      "functions" : ['sales', 'marketing']    } }
Answers:
• String
• Object
• Director
37. Does JSON support Unicode characters?
Answers:
• No, JSON has no support for any kind of character encoding.
• No, JSON only has support for UTF-8 characters.
• Yes, only when stored as the key in a ( key : value ) pair.
• Yes, JSON has support for Unicode characters. Allowing for almost any information in any human language
38. What is JSONP meant to mitigate?
Answers:
• Time's Up!
• Cross-domain communication
• Future proofing JSON as JavaScript changes.
• Size constraints of JSON
39. Of the structures that encompass a value, which can be nested?
Answers:
• True or false only.
• String, number, object, and array only.
• None of them.
• All of them.
40. What is the value of json in the following code?  var obj = {   fruit: 'apple',   toJSON: function ()   {     return 'orange';   } }; var json = JSON.stringify({x: obj});
Answers:
• {"x":"apple"}'
• {"fruit":"orange"}'
• {"fruit":"apple"}'
• {"x":"orange"}'
41. When coding a string object in JSON, what must separate the string and the value?
Answers:
• A semicolon
• A comma
• A colon
• A space
42. JSON strings have to be in
Answers:
• single quote or double quote
• double quote
• single quote
43. What is the value of json in the following code?  var cars = []; cars[0] = 'Ford'; cars[1] = 'Toyota'; cars[2] = 'BMW';   var json = JSON.stringify({x: cars});
Answers:
• {"x":['Ford','Toyota','BMW']}
• {"x":["Ford","Toyota","BMW"]}
• {"x":{"Ford","Toyota","BMW"}}
• {"cars":["Ford","Toyota","BMW"]}
44. What is the value of obj in the following code?  var obj = JSON.parse('{"animal": "cat"}',                      function(k, v)                      {                          if (k == "")                              return v                          else                               return "dog";                      });
Answers:
• { "animal" : "dog"}
• { "animal" : "cat"}
• {"cat"}
• {"dog"}
45. What types of values can you have in JSON key:value pairs?
Answers:
• Strings only
• Strings, Arrays, Primitives and Objects
• Strings, Arrays, and Primitives
• Arrays, Primitives, and Objects stored as strings
46. Which of the following code will return a valid JSON object?
Answers:
• JSON.parse('{"FirstName": "John", "LastName":"Doe"}');
• eval('({"FirstName": "John", "LastName":"Doe"})');
• All three codes are valid
• eval("({'FirstName': 'John', 'LastName':'Doe'})");
47. Which of the following control characters cannot be used when writing a JSON string without escaping?
Answers:
• / or {
• ; or :
• “ or \
• < or >
48. In what situation would you want to use XML over JSON?
Answers:
• When JSON is not offered.
• Never, JSON is worlds better.
• You need message validation or you're using XSLT.
• When you need to use tags to structure your content.
49. What is the return value for JSON.parse()?
Answers:
• Object or Array
• Object
• Array
• String
50. What error does JSON.parse() throw when the string to parse is not valid JSON?
Answers:
• EvalError
• ReferenceError
• TypeError
• SyntaxError
51. What is a JSONStringer used for?
Answers:
• It quickly converts JSON to Java strings.
• It is used to create number strings in JSON.
• It is used to quickly create JSON text.
• It is used to create JSON ordered pairs.
52. What is the value of json in the following code?  var days = {}; days['Monday'] = true; days['Wednesday'] = true; days['Sunday'] = false;  var json = JSON.stringify({x: days});
Answers:
• {"x":{"Monday":true,"Wednesday":true,"Sunday":false}}
• {"x":["Monday":true,"Wednesday":true,"Sunday":false]}
• {"day":{"Monday":"true","Wednesday":"true","Sunday":"false"}}
• {"day":{"Monday":true,"Wednesday":true,"Sunday":false}}
53. How does JSON being "lightweight" translate into a benefit for the site visitors?
Answers:
• Faster transfer times over the internet
• Parsing JSON is noticeably faster than parsing XML
• Web apps have a smaller footprint
54. What two structures is JSON built on?
Answers:
• A collection of name/value pairs, and an ordered list of values, or array.
• A collection of name/value objects, and an ordered list of objects, or array.
• A collection of object/item pairs, and an ordered list of pairs, or array.
• A collection of native-value pairs, and an ordered list of arrays, or values.
55. Which of the following is not a valid way to parse JSON string?
Answers:
• JSON.eval()
• JSON.parse()
• eval()
• jQuery.parseJSON()
56. Which of the following code will not throw an error?
Answers:
• JSON.parse();
• JSON.parse('');
• JSON.parse(null);
• JSON.parse({});
57. Does JSON internally handle validation?
Answers:
• No, JSON expects data to be well-formed and valid because it will not do any validation
• Yes, JSON is not picky about whether or not your JSON is well-formed or valid, it will handle it itself
• Yes, even mal-formed data will can be parsed and validated.
• No, JSON has no validator.
58. What does JSONP stand for?
Answers:
• JSON Programming
• JSON Parsing
• JSON with padding
• JSON Procedures
59. How does JSON handle numeric values that cannot be represented by a sequence of digits (like Infiniti and Nan)?
Answers:
• They are stored fine but it's the parsers job to convert them to numeric values.
• They are stored as strings and then converted when parsed.
• They are not permitted.
60. Is JSON case sensitive?
Answers:
• True
• depends on the value type
• False
61. Which of the following number formats are not used in JSON?
Answers:
• Octal and hexadecimal
• Octal and binary
• Binary and hexadecimal
• Octal and gate
62. What is used by the JSONObject and JSONArray constructors to parse JSON source strings?
Answers:
• ParserJ
• JSONParser
• JParser
• JSONTokener
63. Which statement about the space parameter in JSON.stringify() is false?
Answers:
• It removes whitespace
• All three statements are false
• It is an optional parameter
• It controls spacing in the resulting JSON string
64. True of False.  The order of JSON objects is always preserved.
Answers:
• True
• False
65. True of False? The external form of a JSON object always begins and ends with {}
Answers:
• True

• False

No comments:

Post a Comment