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?
BeginnerShow 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`?
BeginnerShow answer & explanation
Boolean
`true` is a JSON boolean literal, representing a true/false value.
Q3. Which of the following is a valid JSON array?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow answer & explanation
Double quotes
JSON requires strings to be enclosed in double quotes (`"..."`).
Q9. What does the following JSON represent? `{"items": [1, 2, 3]}`
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow answer & explanation
{}
An empty JSON object is represented by a pair of curly braces `{}`.
Q12. Which of the following is a valid JSON number?
BeginnerShow 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?
BeginnerShow answer & explanation
true
JSON booleans are lowercase literals: `true` and `false`.
Q14. In JSON, keys can be unquoted if they contain only letters.
BeginnerShow 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.
BeginnerShow 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`.
BeginnerShow 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.
BeginnerShow 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.
BeginnerShow 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"?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
BeginnerShow 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?
IntermediateShow 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?
IntermediateShow 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"?
IntermediateShow 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?
IntermediateShow 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"?
IntermediateShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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?
AdvancedShow 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…
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