JSON MCQs – JSON Data Types

JSON (JavaScript Object Notation) supports a set of fundamental data types that make it a versatile and widely used data format. These include strings, numbers, objects, arrays, booleans, and null values. A solid grasp of JSON data types is essential for developers working with APIs, configuring applications, or handling data serialization. Knowing how these data types are represented and used can significantly enhance your problem-solving skills during technical interviews. Below are the top MCQs on “JSON Data Types” with explanations to help you prepare effectively.

1.) Which of the following is NOT a valid JSON data type?

A) String
B) Date
C) Number
D) Array

Answer: Option B

Explanation: JSON does not have a native date type. Dates are usually represented as strings.

2.) Which of the following is a valid JSON string?

A) “Hello”
B) ‘Hello’
C) Hello
D) “Hello”

Answer: Option A

Explanation: JSON strings must be enclosed in double quotes (“).

3.) Which of the following JSON values is equivalent to “no value”?

A) undefined
B) null
C) “”
D) none

Answer: Option B

Explanation: The JSON null value represents the absence of a value.

4.) Which of the following is a valid JSON array?

A) [1; 2; 3]
B) {“1”, “2”, “3”}
C) (1, 2, 3)
D) [1, 2, “three”]

Answer: Option D

Explanation: JSON arrays are enclosed in square brackets ([]) and can contain multiple data types.

5.) What data type is represented by {} in JSON?

A) Array
B) String
C) Object
D) Null

Answer: Option C

Explanation: {} represents a JSON object, which consists of key-value pairs.

6.) Can a JSON key have a number as its name?

A) Yes, without quotes
B) Yes, with quotes
C) No
D) Only in arrays

Answer: Option B

Explanation: JSON keys must be strings and must be enclosed in double quotes.

7.) Which JSON data type is used to represent a collection of items?

A) Array
B) Object
C) String
D) Number

Answer: Option A

Explanation: JSON arrays represent a collection of items, enclosed in square brackets.

8.) Which of the following is an example of a valid JSON number?

A) “123”
B) 123
C) 123.45
D) Both B and C

Answer: Option D

Explanation: JSON numbers can be integers or floating-point numbers, but they are not enclosed in quotes.

9.) Which JSON data type is used to group key-value pairs?

A) Object
B) Array
C) String
D) Number

Answer: Option A

Explanation: Objects are used to group key-value pairs in JSON.

10.) How are floating-point numbers represented in JSON?

A) float(1.23)
B) 1.23f
C) “1.23”
D) 1.23

Answer: Option D

Explanation: JSON numbers, including floating-point numbers, are written without quotes or type indicators.

Leave a Reply

Your email address will not be published. Required fields are marked *