1. What does JSON stand for?
a. JavaScript Object Notation
b. JavaScript Object Network
c. JavaScript Object Namespace
d. JavaScript Object Native
Answer: a. JavaScript Object Notation
2. In JSON, data is represented in which format?
a. Text
b. Binary
c. XML
d. HTML
Answer: a. Text
3. Which character is used to separate keys and values in a JSON object?
a. :
b. ,
c. =
d. ;
Answer: a. :
4. In JSON, arrays are enclosed in which characters?
a. {}
b. ()
c. []
d. <>
Answer: c. []
5. Which data types can be stored in a JSON object?
a. String, Number, Boolean, Array, Object
b. String, Integer, Float, List, Dictionary
c. String, Number, List, Set, Map
d. String, Boolean, Array, Object
Answer: a. String, Number, Boolean, Array, Object
6.How do you represent a tab character in a JSON string?
a. \t
b. \t
c. \tab
d. \tab
Answer: a. \t
7. Which function is used to parse a JSON string into a JavaScript object?
a. JSON.parse()
b. JSON.stringify()
c. JSON.parseJSON()
d. JSON.decode()
Answer: a. JSON.parse()
8. Which function is used to convert a JavaScript object to a JSON string?
a. JSON.parse()
b. JSON.stringify()
c. JSON.string()
d. JSON.convert()
Answer: b. JSON.stringify()
9. Is the order of properties preserved in a JSON object?
a. Yes
b. No
Answer: a. Yes
10. Can a JSON object contain nested arrays and objects?
a. Yes
b. No
Answer: a. Yes
11. Which of the following is a valid JSON data type?
a. Date
b. Function
c. Undefined
d. All of the above
Answer: c. Undefined
12. How can you access a value in a JSON object?
a. By index
b. By key
c. By value
d. By property
Answer: b. By key
13. Which method is used to add a new key-value pair to a JSON object?
a. obj.add()
b. obj.insert()
c. obj.assign()
d. obj[key] = value
Answer: d. obj[key] = value
14. Can a JSON object have duplicate keys?
a. Yes
b. No
Answer: b. No
15. Which JavaScript function is used to determine if a value is valid JSON?
a. isJSON()
b. validateJSON()
c. JSON.validate()
d. None of the above
Answer: d. None of the above
16. Which method is used to remove a key-value pair from a JSON object?
a. obj.delete()
b. obj.remove()
c. delete obj[key]
d. obj.pop()
Answer: c. delete obj[key]
17. How do you access an element in a JSON array?
a. By key
b. By index
c. By value
d. By property
Answer: b. By index
18. Which function is used to format a JSON string for readability?
a. JSON.format()
b. JSON.prettyPrint()
c. JSON.formatJSON()
d. JSON.stringify()
Answer: b. JSON.prettyPrint()
19. Which method is used to check if a key exists in a JSON object?
a. obj.keyExists()
b. obj.hasOwnProperty()
c. obj.containsKey()
d. obj.isKeyPresent()
Answer: b. obj.hasOwnProperty()
20. In a JSON object, keys must be of which data type?
a. String
b. Number
c. Boolean
d. All of the above
Answer: a. String
21. Which of the following is not a valid JSON data type?
a. Double
b. Float
c. Number
d. Integer
Answer: b. Float
22. Which method is used to get the length of a JSON object?
a. obj.length()
b. Object.keys(obj).length
c. obj.size()
d. obj.count()
Answer: b. Object.keys(obj).length
23. How do you represent null in a JSON object?
a. null
b. undefined
c. None
d. void
Answer: a. null
24. Which method is used to merge two JSON objects?
a. obj.merge()
b. Object.assign()
c. obj.combine()
d. obj.concat()
Answer: b. Object.assign()
25. Which character is used to separate elements in a JSON array?
a. ,
b. ;
c. :
d. /
Answer: a. ,
26. Can a JSON value be another JSON object?
a. Yes
b. No
Answer: a. Yes
27. Which of the following is not a valid way to create a JSON object in JavaScript?
a. JSON.createObject()
b. {}
c. new Object()
d. Object.create()
Answer: a. JSON.createObject()
28. How do you represent a newline character in a JSON string?
a. \n
b. \n
c. \r
d. \r
Answer: a. \n
29. Which method is used to sort the keys of a JSON object?
a. obj.sortKeys()
b. Object.keys(obj).sort()
c. obj.keys().sort()
d. obj.sort()
Answer: b. Object.keys(obj).sort()
30.How do you convert a JSON string to a JavaScript object?
a. JSON.toObject()
b. JSON.parse()
c. JSON.deserialize()
d. JSON.decode()
Answer: b. JSON.parse()
31. Which of the following is a valid way to represent a JSON object?
a. { key: value }
b. [ key: value ]
c. "key": value
d. key: "value"
Answer: c. "key": value
Top comments (0)