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 _______.

  1. JavaScript Object Notation
  2. Java Object Notation
  3. JavaScript Object Normalization
  4. 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.

  1. xml format
  2. text format
  3. JavaScript
  4. 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.

  1. Ajax
  2. Php
  3. HTML
  4. JavaScript

Answer: D) JavaScript

Explanation:

The JSON syntax is a subset of the JavaScript syntax.


4. Who is the creator of JSON?

  1. Alvin Alexander
  2. Rasmus Lerdorf
  3. Douglas Crockford
  4. Jesse James Garrett

Answer: C) Douglas Crockford

Explanation:

Douglas Crockford is the creator of JSON.


5. In the JSON syntax, data is separated by _____.

  1. Semicolons
  2. Colons
  3. Commas
  4. Hyper

Answer: C) Commas

Explanation:

In the JSON syntax, data is separated by commas.


Advertisement

6. In the JSON syntax, array is written within in ____.

  1. Square brackets
  2. Curley braces
  3. Paratheses
  4. 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?

  1. Simplicity
  2. Openness
  3. Self-Describing
  4. Internationalization
  5. Extensibility
  6. Interoperability
  7. 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?

  1. //
  2. /*…*/
  3. <!-- … -->
  4. 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.

  1. class/object
  2. name/value
  3. datatype/variable
  4. value/=

Answer: B) name/value

Explanation:

In the JSON syntax, data is in name/value pairs.


10. JSON names (keys) require double quotes?

  1. True
  2. False

Answer: A) True

Explanation:

It's true that JSON names (key) require double quotes.


Advertisement

11. JSON names (keys) must be strings?

  1. True
  2. 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?

  1. "name" : "value"
  2. "name" : value
  3. "name" : 'value'
  4. '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?

  1. .jsn
  2. .js
  3. .json
  4. jso

Answer: C) .json

Explanation:

The file type for JSON files is ".json"


14. What is the MIME type for JSON text?

  1. application/json
  2. application/jsn
  3. xml/json
  4. xml/jsn

Answer: A) application/json

Explanation:

The MIME type for JSON text is "application/json".


15. Which is not a JSON data type?

  1. number
  2. string
  3. array
  4. date

Answer: D) date

Explanation:

The "date" is not a valid data type.


Advertisement

16. The undefined is a valid datatype in JSON?

  1. Yes
  2. 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?

  1. { "record":{"name":"Alex", "age":21, "city":"London"} }
  2. { "record"={"name":"Alex", "age":21, "city":"London"} }
  3. { "record":{"name":Alex, "age":21, "city":London} }
  4. { 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?

  1. { students:["Alex", "Alvin", "Bobby"] }
  2. { students=["Alex", "Alvin", "Bobby"] }
  3. { "students":["Alex", "Alvin", "Bobby"] }
  4. { "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"}}
  1. String
  2. Array
  3. Object
  4. 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?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, the values in JSON can be null.


Advertisement

21. How to create JSON Boolean object?

  1. {"name"=true/false}
  2. {'name':true/false}
  3. {"name":true/false}
  4. {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 ________.

  1. to update data into the database
  2. to retrieve data from the database
  3. to exchange data to/from a web server
  4. 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?

  1. JSON.parse()
  2. string.parse()
  3. object.parse()
  4. 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?

  1. JSON.string()
  2. JSON.stringify()
  3. JSON.ToString()
  4. 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"];
  1. const json_arr = JSON.string(arr);
  2. const json_arr = JSON.ToString(arr);
  3. const json_arr = JSON.ArrayToString(arr);
  4. 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?

  1. json_encode()
  2. phpjson_encode()
  3. json_string()
  4. 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?

  1. json_decode()
  2. phpjson_decode()
  3. json_string()
  4. 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.

  1. JSON
  2. json
  3. JSONP
  4. JSONP_Encode()

Answer: C) JSONP

Explanation:

JSONP is a method for sending JSON data without worrying about cross-domain issues.


29. JSONP stands for _____.

  1. JSON with Packing
  2. JSON with Padding
  3. JSON with Parsing
  4. JSON with Prefix

Answer: B) JSON with Padding

Explanation:

JSONP stands for JSON with Padding.


30. Does JSON support the Unicode Characters?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, JSON supports the Unicode Characters.


Advertisement

31. Which of the following code will throw an error?

  1. JSON.parse('{"name":"John", "age":30, "city":"New York"}');
  2. JSON.parse(null);
  3. JSON.parse(undefined);
  4. 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()?

  1. Text
  2. Reviver
  3. Object
  4. 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?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Yes, the order of JSON objects is always preserved.


34. How do you represent a JSON array of strings?

  1. { "days" : { "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" } }
  2. { "days" = [ "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" ] }
  3. { "days" = { "SUN" , "MON" , "TUE" , "WED" , "THU" , "FRI" , "SAT" } }
  4. { "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?

  1. {"students": {{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}} }
  2. {"students"= [{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}] }
  3. {"students"= {{"name":"Alvin", "age":21, "city":"Mumbai"}, {"name":"Alex", "age":24, "city":"Delhi"}} }
  4. {"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 ___.

  1. Name
  2. Key
  3. Value
  4. 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"]}
  1. string
  2. object
  3. class
  4. 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"]}
  1. number
  2. int
  3. integer
  4. 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"
	}
]
  1. object
  2. array
  3. string
  4. 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?

  1. Fractional and Rational
  2. Infinity and Rational
  3. Rational and Irrational
  4. 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.



ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.