Home »
MCQs
JSON Multiple-Choice Questions (MCQs)
JSON stands for JavaScript Object Notation. It is a lightweight text format for storing and transporting data. JSON is "self-describing" and easy to understand.
JSON MCQs: This section contains JSON Multiple-Choice Questions with Answers. These JSON MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of JSON.
List of JSON MCQs
1. JSON stands for _______.
- JavaScript Object Notation
- Java Object Notation
- JavaScript Object Normalization
- JavaScript Object-Oriented Notation
Answer: A) JavaScript Object Notation
Explanation:
JSON stands for JavaScript Object Notation.
2. JSON is a _____ for storing and transporting data.
- xml format
- text format
- JavaScript
- php format
Answer: B) text format
Explanation:
JSON is a text format for storing and transporting data.
3. The JSON syntax is a subset of the _____ syntax.
- Ajax
- Php
- HTML
- JavaScript
Answer: D) JavaScript
Explanation:
The JSON syntax is a subset of the JavaScript syntax.
4. Who is the creator of JSON?
- Alvin Alexander
- Rasmus Lerdorf
- Douglas Crockford
- Jesse James Garrett
Answer: C) Douglas Crockford
Explanation:
Douglas Crockford is the creator of JSON.
5. In the JSON syntax, data is separated by _____.
- Semicolons
- Colons
- Commas
- Hyper
Answer: C) Commas
Explanation:
In the JSON syntax, data is separated by commas.
6. In the JSON syntax, array is written within in ____.
- Square brackets
- Curley braces
- Paratheses
- None of the above
Answer: A) Square brackets
Explanation:
In the JSON syntax, array is written within in square brackets.
7. What are the features of JSON?
- Simplicity
- Openness
- Self-Describing
- Internationalization
- Extensibility
- Interoperability
- All of the above
Answer: G) All of the above
Explanation:
The JSON features are:
- Simplicity
- Openness
- Self-Describing
- Internationalization
- Extensibility
- Interoperability
8. Which is the correct symbol to insert a comment in JSON?
- //
- /*…*/
- <!-- … -->
- JSON doesn't support the comments
Answer: D) JSON doesn't support the comments
Explanation:
JSON doesn't support the comments. But you can add an extra attribute to write the comments.
9. In the JSON syntax, data is in ____ pairs.
- class/object
- name/value
- datatype/variable
- value/=
Answer: B) name/value
Explanation:
In the JSON syntax, data is in name/value pairs.
10. JSON names (keys) require double quotes?
- True
- False
Answer: A) True
Explanation:
It's true that JSON names (key) require double quotes.
11. JSON names (keys) must be strings?
- True
- False
Answer: A) True
Explanation:
It's true that JSON names (keys) must be strings.
12. What is the correct syntax of writing JSON name/value pair, where the value is of string type?
- "name" : "value"
- "name" : value
- "name" : 'value'
- 'name' : 'value'
Answer: A) "name" : "value"
Explanation:
The correct syntax of writing JSON name/value pair, where the value is of string type:
"name" : "value"
13. What is the file type for JSON files?
- .jsn
- .js
- .json
- jso
Answer: C) .json
Explanation:
The file type for JSON files is ".json"
14. What is the MIME type for JSON text?
- application/json
- application/jsn
- xml/json
- xml/jsn
Answer: A) application/json
Explanation:
The MIME type for JSON text is "application/json".
15. Which is not a JSON data type?
- number
- string
- array
- date
Answer: D) date
Explanation:
The "date" is not a valid data type.
16. The undefined is a valid datatype in JSON?
- Yes
- No
Answer: B) No
Explanation:
No, "undefined" is not a valid type in JSON.
17. Which is the correct example of a JSON object with name, age, and city?
- { "record":{"name":"Alex", "age":21, "city":"London"} }
- { "record"={"name":"Alex", "age":21, "city":"London"} }
- { "record":{"name":Alex, "age":21, "city":London} }
- { record :{"name":"Alex", "age":21, "city":"London"} }
Answer: A) { "record":{"name":"Alex", "age":21, "city":"London"} }
Explanation:
The correct example of a JSON object with name, age, and city:
{ "record":{"name":"Alex", "age":21, "city":"London"} }
18. Which of these is an example of a proper JSON array?
- { students:["Alex", "Alvin", "Bobby"] }
- { students=["Alex", "Alvin", "Bobby"] }
- { "students":["Alex", "Alvin", "Bobby"] }
- { "students":[{"Alex", "Alvin", "Bobby"]} }
Answer: C) { "students":["Alex", "Alvin", "Bobby"] }
Explanation:
The example of a proper JSON array is:
{ "students":["Alex", "Alvin", "Bobby"] }
19. In the below statement, what is the type of "student"?
{"student":{"name":"Alvin", "age":21, "city":"Mumbai"}}
- String
- Array
- Object
- Class
Answer: C) Object
Explanation:
In the statement: {"student":{"name":"Alvin", "age":21, "city":"Mumbai"}}
The student is an object.
20. Values in JSON can be null?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the values in JSON can be null.
21. How to create JSON Boolean object?
- {"name"=true/false}
- {'name':true/false}
- {"name":true/false}
- {name:true/false}
Answer: C) {"name":true/false}
Explanation:
The syntax to create a JSON Boolean object:
{"name":true/false}
22. A common use of JSON is ________.
- to update data into the database
- to retrieve data from the database
- to exchange data to/from a web server
- None of the above
Answer: C) to exchange data to/from a web server
Explanation:
A common use of JSON is to exchange data to/from a web server.
23. Which function is used to convert text into a JavaScript object?
- JSON.parse()
- string.parse()
- object.parse()
- All of the above
Answer: A) JSON.parse()
Explanation:
The JSON.parse() function is used to convert text into a JavaScript object.
24. Which function is used to convert a JavaScript object into a string?
- JSON.string()
- JSON.stringify()
- JSON.ToString()
- All of the above
Answer: B) JSON.stringify()
Explanation:
The JSON.stringify() function is used to convert a JavaScript object into a string.
25. Which is the correct statement to convert the below given array to string?
const arr = ["Alex", "Alvin", "Bobby", "Dock"];
- const json_arr = JSON.string(arr);
- const json_arr = JSON.ToString(arr);
- const json_arr = JSON.ArrayToString(arr);
- const json_arr = JSON.stringify(arr);
Answer: D) const json_arr = JSON.stringify(arr);
Explanation:
The correct statement to convert an array to string is:
const arr = ["Alex", "Alvin", "Bobby", "Dock"];
const json_arr = JSON.stringify(arr);
26. Which PHP function is used to convert PHP objects into JSON?
- json_encode()
- phpjson_encode()
- json_string()
- json_object()
Answer: A) json_encode()
Explanation:
The PHP function json_encode() is used to convert PHP objects into JSON.
27. Which PHP function is used to convert the request into an object?
- json_decode()
- phpjson_decode()
- json_string()
- json_object()
Answer: A) json_decode()
Explanation:
The PHP function json_decode() is used to convert the request into an object.
28. ______ is a method for sending JSON data without worrying about cross-domain issues.
- JSON
- json
- JSONP
- JSONP_Encode()
Answer: C) JSONP
Explanation:
JSONP is a method for sending JSON data without worrying about cross-domain issues.
29. JSONP stands for _____.
- JSON with Packing
- JSON with Padding
- JSON with Parsing
- JSON with Prefix
Answer: B) JSON with Padding
Explanation:
JSONP stands for JSON with Padding.
30. Does JSON support the Unicode Characters?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, JSON supports the Unicode Characters.
31. Which of the following code will throw an error?
- JSON.parse('{"name":"John", "age":30, "city":"New York"}');
- JSON.parse(null);
- JSON.parse(undefined);
- JSON.parse('[]');
Answer: C) JSON.parse(undefined);
Explanation:
The following statement will throw an error:
JSON.parse(undefined);
32. What is/are the parameter(s) of the method JSON.parse()?
- Text
- Reviver
- Object
- Both Text and Reviver
Answer: D) Both Text and Reviver
Explanation:
Both Text and Reviver can be used as the parameters in the JSON.parse() function.
33. The order of JSON objects is always preserved?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the order of JSON objects is always preserved.
34. How do you represent a JSON array of strings?
- { "days" : { "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" } }
- { "days" = [ "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" ] }
- { "days" = { "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" } }
- { "days" : [ "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" ] }
Answer: D) { "days" : [ "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" ] }
Explanation:
A JSON array of strings can be represented by the below format/syntax:
{ "days" : [ "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" ] }
35. How do you represent a JSON array of objects?
- {"students": {{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}} }
- {"students"= [{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}] }
- {"students"= {{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}} }
- {"students": [{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}] }
Answer: D) {"students": [{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}] }
Explanation:
A JSON array of objects can be represented by the below format/syntax:
{"students": [{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}] }
36. JSON array elements can be access by ___.
- Name
- Key
- Value
- Index
Answer: D) Index
Explanation:
JSON array elements can be accessed by the index. And Array indexing starts with 0.
37. In the below statement, what is the type of "sports"?
{"name":"Alvin", "age":21, "sports":["Cricket", "Football", "Running"]}
- string
- object
- class
- attribute
Answer: B) object
Explanation:
In the below statement, the type of sports is an object:
{"name":"Alvin", "age":21, "sports":["Cricket", "Football", "Running"]}
38. In the below statement, what is the type of "age"?
{"name":"Alvin", "age":21, "sports":["Cricket", "Football", "Running"]}
- number
- int
- integer
- long
Answer: A) number
Explanation:
In the below statement, the type of age is a number:
{"name":"Alvin", "age":21, "sports":["Cricket", "Football", "Running"]}
39. In the below statement, what data type is encoded in the outermost component?
[
{
"Name" : "Alex
},
{
"Course" : "B.Tech"
}
]
- object
- array
- string
- XML
Answer: B) array
Explanation:
The data type is encoded in the outermost component the given JSON is an array.
40. Which number types are available in the JavaScript but not supported in the JSON?
- Fractional and Rational
- Infinity and Rational
- Rational and Irrational
- Infinity and NaN
Answer: D) Infinity and NaN
Explanation:
The Infinity and NaN data types are available in the JavaScript but not supported in the JSON.