Create a flash card for json: 33 MCQs with answers

All 33 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 23 questions

Q1. Which of the following is the correct JSON syntax for a key-value pair?

Beginner
A key = value B key: value C "key": value D "key" = "value"
Show answer & explanation

"key": value

In JSON, keys must be double-quoted strings, and the key-value pair is separated by a colon.

Q2. What data type is the JSON value `true`?

Beginner
A Boolean B String C Object D Number
Show answer & explanation

Boolean

`true` is a JSON boolean literal, representing a true/false value.

Q3. Which of the following is a valid JSON array?

Beginner
A ["apple", "banana", "cherry"] B <"apple", "banana", "cherry"> C ("apple", "banana", "cherry") D {"apple", "banana", "cherry"}
Show answer & explanation

["apple", "banana", "cherry"]

JSON arrays are enclosed in square brackets `[]` and contain comma-separated values.

Q4. What is the correct JSON representation of a number?

Beginner
A forty-two B 42 C '42' D "42"
Show answer & explanation

42

In JSON, numbers are written without quotes. `42` is a number; `"42"` is a string.

Q5. Which of the following JSON objects is syntactically correct?

Beginner
A {"name": "Alice", "age": 30 B {"name": "Alice", "age": 30} C {"name": "Alice", "age": 30,} D {name: "Alice", age: 30}
Show answer & explanation

{"name": "Alice", "age": 30}

JSON object keys must be double-quoted, and the last key-value pair must not have a trailing comma.

Q6. What is the JSON value for null?

Beginner
A undefined B "null" C null D None
Show answer & explanation

null

In JSON, the null value is written as the literal `null` (without quotes).

Q7. Which of the following is NOT a valid JSON value type?

Beginner
A Array B Function C String D Object
Show answer & explanation

Function

JSON supports only strings, numbers, booleans, null, objects, and arrays. Functions are not valid JSON.

Q8. How are strings enclosed in JSON?

Beginner
A Double quotes B Single quotes C No quotes D Backticks
Show answer & explanation

Double quotes

JSON requires strings to be enclosed in double quotes (`"..."`).

Q9. What does the following JSON represent? `{"items": [1, 2, 3]}`

Beginner
A An array of objects B An object with a key "items" whose value is an array of numbers C An object with a key "items" whose value is a string D An array containing an object
Show answer & explanation

An object with a key "items" whose value is an array of numbers

The outer braces `{}` denote an object. The key `"items"` has a value that is an array `[1, 2, 3]`.

Q10. Which of the following is a valid JSON string?

Beginner
A "Hello World' B 'Hello World' C Hello World D "Hello World"
Show answer & explanation

"Hello World"

A valid JSON string must be enclosed in double quotes. `"Hello World"` meets this requirement.

Q11. What is the correct JSON syntax for an empty object?

Beginner
A "{}" B null C [] D {}
Show answer & explanation

{}

An empty JSON object is represented by a pair of curly braces `{}`.

Q12. Which of the following is a valid JSON number?

Beginner
A "3.14" B 3.14.0 C 3.14 D 3,14
Show answer & explanation

3.14

JSON numbers can be integers or decimals, using a dot as the decimal separator. `3.14` is valid.

Q13. What is the correct JSON representation of a boolean value?

Beginner
A true B TRUE C "true" D True
Show answer & explanation

true

JSON booleans are lowercase literals: `true` and `false`.

Q14. In JSON, keys can be unquoted if they contain only letters.

Beginner
A True B False
Show answer & explanation

False

JSON requires all object keys to be double-quoted strings, regardless of content.

Q15. A JSON array can contain a mix of different data types, such as strings, numbers, and objects.

Beginner
A True B False
Show answer & explanation

True

JSON arrays are ordered lists of values, and the values can be of any valid JSON type, including mixed types.

Q16. The JSON value `"null"` is the same as the JSON value `null`.

Beginner
A True B False
Show answer & explanation

False

`"null"` is a string containing the word 'null', while `null` is the JSON null literal representing an empty value.

Q17. Whitespace (spaces, tabs, newlines) is allowed in JSON to improve readability.

Beginner
A True B False
Show answer & explanation

True

JSON allows arbitrary whitespace between tokens, which can be used for formatting.

Q18. A JSON object must have at least one key-value pair.

Beginner
A True B False
Show answer & explanation

False

An empty JSON object `{}` is perfectly valid and contains zero key-value pairs.

Q19. Which of the following is the correct JSON syntax for a key-value pair where the key is "name" and the value is "Alice"?

Beginner
A `"name": "Alice"` B `"name": Alice` C `name: Alice` D `name: "Alice"`
Show answer & explanation

`"name": "Alice"`

In JSON, both keys and string values must be enclosed in double quotes. The correct syntax is `"name": "Alice"`.

Q20. What is the correct JSON representation of an empty array?

Beginner
A `null` B `[""]` C `{}` D `[]`
Show answer & explanation

`[]`

An empty array in JSON is represented by a pair of square brackets with nothing inside: `[]`. Curly braces `{}` denote an empty object, `[""]` is an array with one empty string, and `null` is a null value.

Q21. Which of the following is a valid JSON object with one key-value pair?

Beginner
A `{score: 95}` B `{"score": 95,}` C `{"score": 95}` D `{"score": 95`
Show answer & explanation

`{"score": 95}`

A valid JSON object must have keys in double quotes, a colon between key and value, and no trailing comma. `{"score": 95}` meets all requirements. `{score: 95}` has an unquoted key, `{"score": 95,}` has a trailing comma, and `{"score": 95` is missing the closing brace.

Q22. What is the correct JSON syntax for a string value?

Beginner
A `Hello` B `Hello` (without quotes) C `'Hello'` D `"Hello"`
Show answer & explanation

`"Hello"`

In JSON, strings must be enclosed in double quotes. Single quotes or no quotes are not valid JSON syntax. Therefore, `"Hello"` is the correct representation.

Q23. Which of the following JSON snippets contains a trailing comma that makes it invalid?

Beginner
A `{"a": 1}` B `{"a": 1, "b": 2,}` C `{"a": 1, "b": 2}` D `[1, 2, 3]`
Show answer & explanation

`{"a": 1, "b": 2,}`

JSON does not allow trailing commas. The snippet `{"a": 1, "b": 2,}` has a comma after the last key-value pair, which is invalid. The other options have no trailing commas and are valid.

Building up · 5 questions

Q24. Consider the following JSON snippet: ```json { "flashcards": [ {"front": "What is JSON?", "back": "A data format"}, {"front": "What is a key?", "back": "A string identifier"}, ] } ``` Why is this JSON invalid?

Intermediate
A The array `"flashcards"` contains objects with different key names. B The strings inside the objects use double quotes, which is not allowed. C There is a trailing comma after the last object in the array. D The key `"flashcards"` must be enclosed in single quotes.
Show answer & explanation

There is a trailing comma after the last object in the array.

JSON does not allow trailing commas. The comma after the second object (before the closing `]`) is a syntax error. Keys must always be double-quoted, and single quotes are not valid in JSON.

Q25. Given the requirement to store a flash card with a mathematical expression as the "front" and its LaTeX representation as the "back", which of the following JSON objects correctly represents this data?

Intermediate
A ```json {"front": $E = mc^2$, "back": "E = mc^2"} ``` B ```json {"front": "$E = mc^2$", "back": "The equation $E = mc^2$ represents mass-energy equivalence."} ``` C ```json {"front": "E = mc^2", "back": "$E = mc^2$"} ``` D ```json {"front": "E = mc^2", "back": "$$E = mc^2$$"} ```
Show answer & explanation

```json {"front": "$E = mc^2$", "back": "The equation $E = mc^2$ represents mass-energy equivalence."} ```

In JSON, all string values must be enclosed in double quotes. Option C correctly uses double quotes for both the front (which contains LaTeX inline math `$E = mc^2$`) and the back. Option A and B are missing quotes around the values, and Option D has unquoted LaTeX as the front value, which is invalid JSON.

Q26. A developer creates a JSON structure for a set of flash cards where each card has a "tags" field that can contain multiple tags. Which of the following JSON snippets correctly represents a card with the tags "math", "physics", and "relativity"?

Intermediate
A ```json {"question": "What is E=mc^2?", "tags": ("math", "physics", "relativity")} ``` B ```json {"question": "What is E=mc^2?", "tags": [math, physics, relativity]} ``` C ```json {"question": "What is E=mc^2?", "tags": ["math", "physics", "relativity"]} ``` D ```json {"question": "What is E=mc^2?", "tags": "math, physics, relativity"} ```
Show answer & explanation

```json {"question": "What is E=mc^2?", "tags": ["math", "physics", "relativity"]} ```

JSON arrays are enclosed in square brackets `[]` and contain comma-separated values. Option A correctly uses an array of strings. Option B uses parentheses (invalid in JSON). Option C uses a single string, not an array. Option D has unquoted strings, which are not valid JSON values.

Q27. Compare the following two JSON structures for storing a flash card with nested metadata: Structure 1: ```json { "card": { "front": "Define JSON", "back": "JavaScript Object Notation", "metadata": {"difficulty": "easy", "created": "2023-01-01"} } } ``` Structure 2: ```json { "card": { "front": "Define JSON", "back": "JavaScript Object Notation", "metadata": {"difficulty": "easy", "created": "2023-01-01",} } } ``` Which statement is correct?

Intermediate
A Structure 1 is valid; Structure 2 is invalid due to a trailing comma in the nested `"metadata"` object. B Structure 2 is valid because trailing commas are allowed in nested objects. C Neither structure is valid because the `"card"` key must be a string without quotes. D Both structures are valid JSON because nested objects are allowed.
Show answer & explanation

Structure 1 is valid; Structure 2 is invalid due to a trailing comma in the nested `"metadata"` object.

JSON does not permit trailing commas anywhere. Structure 2 has a trailing comma after the last key-value pair in the `"metadata"` object (after `"2023-01-01"`), making it invalid. Structure 1 has no trailing commas and is valid. Keys must always be double-quoted, so the last option is incorrect.

Q28. A flash card application stores cards in a JSON array. Which of the following JSON arrays is syntactically correct and contains exactly three cards, each with a "front" and "back"?

Intermediate
A ```json [ {"front": "Q1", "back": "A1"}, {"front": "Q2", "back": "A2"} {"front": "Q3", "back": "A3"} ] ``` B ```json [ {"front": "Q1", "back": "A1"}, {"front": "Q2", "back": "A2"}, {"front": "Q3", "back": "A3"}, ] ``` C ```json [ {"front": "Q1", "back": "A1"} {"front": "Q2", "back": "A2"} {"front": "Q3", "back": "A3"} ] ``` D ```json [ {"front": "Q1", "back": "A1"}, {"front": "Q2", "back": "A2"}, {"front": "Q3", "back": "A3"} ] ```
Show answer & explanation

```json [ {"front": "Q1", "back": "A1"}, {"front": "Q2", "back": "A2"}, {"front": "Q3", "back": "A3"} ] ```

Option A is valid: it has three objects separated by commas, with no trailing comma after the last object. Option B is missing a comma between the second and third objects. Option C has a trailing comma after the third object. Option D has no commas between the objects, which is invalid JSON.

Topper level · 5 questions

Q29. A flash card system stores cards in a JSON array. Each card has a "front" (string), "back" (string), and "tags" (array of strings). A developer writes the following JSON: ```json [ { "front": "E = mc^2", "back": "Energy equals mass times speed of light squared", "tags": ["physics", "relativity"] }, { "front": "F = ma", "back": "Newton's second law", "tags": ["physics", "mechanics"] }, { "front": "a^2 + b^2 = c^2", "back": "Pythagorean theorem", "tags": ["math", "geometry"] } ] ``` This JSON is syntactically valid. However, the developer wants to add a fourth card with a "front" that contains a LaTeX expression: $\int_{a}^{b} f(x) \, dx$. Which of the following is the correct JSON representation for the fourth card, ensuring the LaTeX is stored as a string and the JSON remains valid?

Advanced
A ```json { "front": "$\int_{a}^{b} f(x) \, dx$", "back": "Definite integral", "tags": ["math", "calculus"] } ``` B ```json { "front": "$\\int_{a}^{b} f(x) \\, dx$", "back": "Definite integral", "tags": ["math", "calculus"] } ``` C ```json { "front": "$\int_{a}^{b} f(x) \, dx$", "back": "Definite integral", "tags": ["math", "calculus"] } ``` D ```json { "front": "$\int_{a}^{b} f(x) \, dx$", "back": "Definite integral", "tags": ["math", "calculus"] } ```
Show answer & explanation

```json { "front": "$\\int_{a}^{b} f(x) \\, dx$", "back": "Definite integral", "tags": ["math", "calculus"] } ```

In JSON strings, the backslash `\` is an escape character. To represent a literal backslash (as needed for LaTeX commands like `\int` or `\,`), each backslash must be escaped with another backslash, resulting in `\\`. Option B correctly uses `\\int` and `\\,`, while the other options use single backslashes, which would…

Q30. A developer creates a JSON file for flash cards with nested metadata. The following JSON snippet is intended to represent a single card with a "front", "back", and a "metadata" object containing "difficulty" and "created" fields: ```json { "card": { "front": "What is the derivative of $x^2$?", "back": "$2x$", "metadata": { "difficulty": "hard", "created": "2024-05-01" } } } ``` After validation, the developer finds that the JSON is invalid. Which of the following is the most likely reason?

Advanced
A The date "2024-05-01" is not a valid JSON data type; dates must be represented as strings. B The JSON uses a nested object for "metadata", but JSON does not support nested objects. C The "front" value contains a LaTeX expression with `$` symbols, which are not allowed in JSON strings. D The "metadata" object is missing a comma after the "created" key-value pair.
Show answer & explanation

—

The JSON snippet as shown is actually syntactically valid. None of the provided options correctly identify an error. However, the question states that the JSON is invalid, implying a hidden issue. The most plausible hidden error is that the LaTeX expression in the "front" field contains a backslash that is not escaped.…

Q31. A flash card application imports a JSON file containing an array of cards. The file has the following structure: ```json [ { "front": "What is the capital of France?", "back": "Paris" }, { "front": "What is the square root of 16?", "back": "4" }, { "front": "What is the boiling point of water?", "back": "100°C" } ] ``` A developer notices that the third card's "back" value contains the degree symbol (°). The JSON parser throws an error. Which of the following is the most likely cause?

Advanced
A The array contains three objects, but JSON arrays can only hold up to two objects. B The degree symbol is a reserved character in JSON and must be escaped with a backslash. C The JSON file is not encoded in UTF-8, causing the degree symbol to be misinterpreted. D The degree symbol is not a valid UTF-8 character, so it must be escaped as `\u00b0`.
Show answer & explanation

The JSON file is not encoded in UTF-8, causing the degree symbol to be misinterpreted.

JSON strings can contain any Unicode character, including the degree symbol (°), as long as the file is encoded in UTF-8 (or another Unicode encoding). The most likely cause of the error is that the JSON file is saved with a non-UTF-8 encoding (e.g., ISO-8859-1), causing the degree symbol to be invalid. Option B correc…

Q32. A developer needs to store a flash card with a mathematical formula that includes a fraction. The front of the card is: "Solve for x: $\frac{3x + 2}{5} = 7$". The developer writes the following JSON: ```json { "front": "Solve for x: $\frac{3x + 2}{5} = 7$", "back": "x = 11" } ``` When parsed, this JSON is invalid. Which of the following corrections will make the JSON valid while preserving the LaTeX expression exactly as intended?

Advanced
A Remove the dollar signs: `\frac{3x + 2}{5} = 7`. B Enclose the entire string in single quotes instead of double quotes. C Replace the backslashes with forward slashes: `$\frac{3x + 2}{5} = 7$` becomes `$/frac{3x + 2}{5} = 7$`. D Escape each backslash with an additional backslash: `$\\frac{3x + 2}{5} = 7$`.
Show answer & explanation

Escape each backslash with an additional backslash: `$\\frac{3x + 2}{5} = 7$`.

In JSON, the backslash is an escape character. To include a literal backslash in a string, it must be escaped as `\\`. The original string has `\frac`, where the backslash is interpreted as the start of an escape sequence (e.g., `\f` is a form feed character), making the JSON invalid. Escaping each backslash with anoth…

Q33. A flash card dataset is stored in a JSON file with the following structure: ```json { "deck": "Advanced Math", "cards": [ { "front": "What is the integral of $e^x$?", "back": "$e^x + C$" }, { "front": "What is the limit of $1/x$ as $x \\to \\infty$?", "back": "0" } ] } ``` A developer claims that this JSON is invalid because the second card's "front" contains a LaTeX expression with escaped backslashes (`\\to` and `\\infty`). Which of the following statements is correct?

Advanced
A The developer is incorrect; the JSON is valid because the double backslashes correctly represent literal backslashes in the LaTeX expression. B The developer is correct; the JSON is invalid because the second card's "front" contains a space after the comma in `$x \\to \\infty$`, which is not allowed. C The developer is incorrect; the JSON is valid only if the entire file is encoded in ASCII, but the presence of `$` symbols makes it invalid. D The developer is correct; the double backslashes are not valid in JSON strings and must be single backslashes.
Show answer & explanation

The developer is incorrect; the JSON is valid because the double backslashes correctly represent literal backslashes in the LaTeX expression.

In JSON, to include a literal backslash in a string, it must be escaped as `\\`. The second card's "front" correctly uses `\\to` and `\\infty`, which when parsed become `\to` and `\infty`—the intended LaTeX commands. Thus, the JSON is syntactically valid. Option B correctly states this. Option A is false because single…

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages