Top 50 YAML Interview Questions with Answers

YAML Interview Questions with Answers
  1. What does YAML stand for?
    a) Yet Another Markup Language
    b) YAML Ain’t Markup Language
    c) YAML Asks for Markup Language
    d) You Are Markup Language

Answer: b) YAML Ain’t Markup Language

  1. Which data types can be represented in YAML?
    a) Strings
    b) Integers
    c) Boolean
    d) All of the above

Answer: d) All of the above

  1. Which character is used to indicate a comment in YAML?
    a) #
    b) !
    c) *
    d) –

Answer: a)

  1. YAML is a:
    a) Markup language
    b) Scripting language
    c) Data serialization format
    d) None of the above

Answer: c) Data serialization format

  1. Which character is used to represent a sequence in YAML?
    a) !
    b) –
    c) ?
    d) :

Answer: b) –

  1. Which character is used to represent a mapping in YAML?
    a) !
    b) –
    c) ?
    d) :

Answer: d) :

  1. What is the extension of YAML files?
    a) .yaml
    b) .yml
    c) .yamlml
    d) .yam

Answer: b) .yml

  1. Which of the following is NOT a scalar data type in YAML?
    a) Integer
    b) String
    c) List
    d) Boolean

Answer: c) List

  1. Which of the following is a correct way to represent a block-style sequence in YAML?

a) –
item1
item2
item3

b) – item1, item2, item3

c) [item1, item2, item3]

d) (item1, item2, item3)

Answer:

a) –
item1
item2
item3

  1. Is indentation important in YAML?
    a) Yes
    b) No

Answer: a) Yes

  1. Which character is used to indicate the start of a new line in a YAML string?
    a) \
    b) |
    c) !
    d) &

Answer: b) |

  1. What is the difference between mapping and sequence in YAML?
    a) Mapping is key-value pairs while sequence is a list of values.
    b) Mapping is a list of values while sequence is key-value pairs.
    c) Mapping and sequence are identical in YAML.
    d) None of the above.

Answer: a) Mapping is key-value pairs while sequence is a list of values.

  1. Which of the following is NOT a valid way to represent a Boolean value in YAML?
    a) True
    b) true
    c) Yes
    d) On

Answer: d) On

  1. What is the difference between null and empty string in YAML?
    a) Null represents absence of a value while an empty string is a value that has no characters.
    b) Null and empty string can be used interchangeably in YAML.
    c) Null and empty string are identical in YAML.
    d) None of the above.

Answer: a) Null represents absence of a value while an empty string is a value that has no characters.

  1. Which of the following is a correct way to represent a block-style mapping in YAML?

a) person: {name: John, age: 40}

b) person:
name: John
age: 40

c) person: [name: John, age: 40]

d) person: (name: John, age: 40)

Answer:

b) person:
name: John
age: 40

  1. Which of the following is NOT a valid way to represent a null value in YAML?
    a) null
    b) ~
    c) Null
    d) None of the above

Answer: c) Null

  1. Which of the following is NOT a scalar data type in YAML?
    a) Integer
    b) String
    c) Mapping
    d) Boolean

Answer: c) Mapping

  1. Which of the following is the correct way to include a YAML file within another YAML file?
    a) &file include “filename.yml”
    b) << include “filename.yml”
    c) !include “filename.yml”
    d) #include “filename.yml”

Answer: c) !include “filename.yml”

  1. Which character is used to indicate a nested structure in YAML?
    a) .
    b) :
    c) >
    d) \

Answer: a) .

  1. What is the difference between a scalar and a non-scalar data type in YAML?
    a) Scalar data types have a single value while non-scalar data types can have multiple values.
    b) Scalar data types can be modified while non-scalar data types are fixed.
    c) Scalar data types are key-value pairs while non-scalar data types are lists of values.
    d) None of the above.

Answer: a) Scalar data types have a single value while non-scalar data types can have multiple values.

  1. What is the difference between a flow style and block style in YAML?
    a) Flow style is a compressed format while block style is a more spaced out format.
    b) Flow style does not require indentation while block style does.
    c) Flow style is a single line while block style is multiline.
    d) All of the above.

Answer: d) All of the above.

  1. Which of the following is a correct way to represent a multi-line string in YAML?

a) This is a multi-line string.

b) This is a \n
multi-line \n
string.

c) |
This is a
multi-line
string.

d) –
This is a
multi-line
string.

Answer: c) |

This is a
multi-line
string.

  1. Which of the following is NOT a valid way to represent a mapping key in YAML?
    a) key: value
    b) ‘key’: value
    c) “key”: value
    d) $key: value

Answer: d) $key: value

  1. Which of the following is a correct way to represent a block-style sequence of sequences in YAML?

a) –

  • item1
  • item2
  • item3
  • item4

b) [item1, item2], [item3, item4]

c) (item1, item2), (item3, item4)

d) –

  • [item1, item2]
  • [item3, item4]

Answer:

d) –

  • [item1, item2]
  • [item3, item4]
  1. What is the difference between an alias and an anchor in YAML?
    a) An alias refers to an anchor while an anchor refers to a specific location.
    b) An anchor is used to create an alias while an alias is used to reference an anchor.
    c) An alias and an anchor are identical in YAML.
    d) None of the above.

Answer: b) An anchor is used to create an alias while an alias is used to reference an anchor.

  1. Which of the following is a correct way to represent a tagged value in YAML?

a) !tag value

b) – !tag value

c) !tag
value

d) None of the above.

Answer: c) !tag

value

  1. What is the difference between a single-quoted and double-quoted string in YAML?
    a) Single-quoted strings cannot contain escape sequences while double-quoted strings can.
    b) Double-quoted strings cannot contain escape sequences while single-quoted strings can.
    c) Single-quoted strings are case sensitive while double-quoted strings are not.
    d) None of the above.

Answer: a) Single-quoted strings cannot contain escape sequences while double-quoted strings can.

  1. Which of the following is a correct way to represent a block-style map of scalar values in YAML?

a) {key1: value1, key2: value2}

b) –
key1: value1
key2: value2

c) key1: value1
key2: value2

d) None of the above.

Answer: c) key1: value1

key2: value2

  1. Which character is used to represent an escape sequence in YAML?
    a) \
    b) %
    c) $
    d) @

Answer: a) \

  1. Which of the following is NOT a valid way to represent a date in YAML?
    a) 2021-07-27
    b) 20210727
    c) ‘2021-07-27’
    d) 07/27/2021

Answer: d) 07/27/2021

  1. The default mapping style in YAML is:
    a) Flow
    b) Block

Answer: b) Block

  1. Which of the following is a reserved keyword in YAML?
    a) include
    b) list
    c) task
    d) None of the above.

Answer: a) include

  1. Which character is used to indicate a literal scalar value in YAML?
    a) |
    b) >
    c) &
    d) !

Answer: a) |

  1. Which character is used to indicate a folded scalar value in YAML?
    a) |
    b) >
    c) &
    d) !

Answer: b) >

  1. The default scalar style in YAML is:
    a) Single-quoted
    b) Double-quoted
    c) Plain
    d) None of the above.

Answer: c) Plain

  1. Which of the following is NOT a valid way to represent a timestamp in YAML?
    a) 2021-07-27T10:23:15Z
    b) 20210727102315
    c) ‘2021-07-27T10:23:15Z’
    d) 07/27/2021 10:23:15

Answer: d) 07/27/2021 10:23:15

  1. Which of the following is a correct way to indicate a tag in YAML?

a) !tag
b) tag:
c) #tag
d) @tag

Answer: a) !tag

  1. Which character is used to indicate that a scalar value should be represented in block style?
    a) |
    b) >
    c) []
    d) {}

Answer: a) |

  1. Which of the following is a correct way to represent a block-style map of non-scalar values in YAML?

a) {key1: [value1, value2], key2: {subkey1: value3, subkey2: value4}}

b) –
key1:

  • value1
  • value2
    key2:
    subkey1: value3
    subkey2: value4

c) key1: [value1, value2]
key2: {subkey1: value3, subkey2: value4}

d) None of the above.

Answer:

b) –
key1:

  • value1
  • value2
    key2:
    subkey1: value3
    subkey2: value4
  1. Which character is used to indicate that a scalar value should be represented in flow style?
    a) |
    b) >
    c) []
    d) {}

Answer: d) {}

  1. Which of the following is a correct way to include a scalar value from another YAML file?

a) &file include “filename.yml”
b) << include “filename.yml”
c) !include “filename.yml”
d) #include “filename.yml”

Answer: b) << include “filename.yml”

  1. Which of the following is NOT a valid way to represent a list in YAML?
    a) [- item1, item2]
    b) [item1, item2]
    c) –
  • item1
  • item2
    d) {item1: value1, item2: value2}

Answer: d) {item1: value1, item2: value2}

  1. Which of the following is a correct way to represent a block-style literal scalar value in YAML?

a) |
This is a
literal scalar
value.

b) \
This is a \
literal scalar \
value.

c) ‘
This is a
literal scalar
value.’

d) “
This is a
literal scalar
value.”

Answer: a) |

This is a
literal scalar
value.

  1. Which character is used to indicate a folded scalar value with indentation in YAML?
    a) |
    b) >
    c) +
    d) <

Answer: d) <

  1. Which of the following is a correct way to represent a flow-style map of non-scalar values in YAML?

a) {key1: [value1, value2], key2: {subkey1: value3, subkey2: value4}}

b) key1: [value1, value2], key2: {subkey1: value3, subkey2: value4}

c) –
{key1: [value1, value2]}
{key2: {subkey1: value3, subkey2: value4}}

d) None of the above.

Answer: a) {key1: [value1, value2], key2: {subkey1: value3, subkey2: value4}}

  1. Which character is used to indicate a folded scalar value with no indentation in YAML?
    a) |
    b) >
    c) +
    d) <

Answer: c) +

  1. What does a YAML file start with?
    a) —
    b) ===
    c) ***
    d) |||

Answer: a) —

  1. Which of the following is a correct way to represent an alias in YAML?
    a) &alias value
    b) *alias
    c) !alias value
    d) None of the above.

Answer: b) *alias

  1. Which of the following is a built-in tag in YAML?
    a) !include
    b) !null
    c) !empty
    d) None of the above.

Answer: b) !null

  1. What is the basic structure of a YAML document?
    a) Comment, Scalar, Sequence, Mapping
    b) Scalar, Sequence, Mapping, Comment
    c) Mapping, Sequence, Scalar, Comment
    d) None of the above.

Answer: b) Scalar, Sequence, Mapping, Comment

Ashwani Kumar
Latest posts by Ashwani Kumar (see all)
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x