What does the '+' wildcard represent in MQTT topic subscriptions?
The '+' wildcard matches exactly one level in the topic hierarchy. It acts like a placeholder for any single topic name at that level.
Click to reveal answer
beginner
What does the '#' wildcard represent in MQTT topic subscriptions?
The '#' wildcard matches any number of levels, including zero, in the topic hierarchy. It must be the last character in the subscription.
Click to reveal answer
beginner
How would you subscribe to all topics under 'home/kitchen' using wildcards?
Use the subscription 'home/kitchen/#' to receive messages from 'home/kitchen' and all its subtopics.
Click to reveal answer
intermediate
Can the '+' wildcard be used multiple times in a single MQTT subscription?
Yes, '+' can be used multiple times to match one level at each position in the topic hierarchy.
Click to reveal answer
intermediate
Why must the '#' wildcard be the last character in an MQTT subscription?
Because '#' matches all remaining levels, placing it last ensures the subscription covers all subtopics beyond that point without ambiguity.
Click to reveal answer
What does the MQTT subscription 'home/+/temperature' match?
AOnly the topic 'home/+/temperature'
BAll topics starting with 'home/temperature'
CAll topics with 'home' as first level, any second level, and 'temperature' as third level
DAll topics under 'home' regardless of levels
✗ Incorrect
The '+' wildcard matches exactly one level, so 'home/+/temperature' matches topics like 'home/kitchen/temperature' or 'home/livingroom/temperature'.
Which MQTT subscription matches all topics under 'office' including sublevels?
Aoffice/+
Boffice/#
C#/office
D+/office/#
✗ Incorrect
'office/#' matches 'office' and all its subtopics at any level.
Is 'home/#/temperature' a valid MQTT subscription?
ANo, '#' must be the last character
BYes, it matches all topics under 'home' with 'temperature' at the end
CYes, but only matches 'home/#/temperature' literally
DNo, '+' should be used instead of '#'
✗ Incorrect
The '#' wildcard must be the last character in the subscription.
What does the subscription '+/sensor/#' match?
AAll topics with 'sensor' anywhere
BOnly topics starting with '+/sensor/'
COnly topics with exactly two levels
DAny topic with any first level, 'sensor' as second level, and any subtopics after
✗ Incorrect
'+' matches one level, so the first level can be anything, then 'sensor', then any subtopics with '#'.
Which wildcard matches exactly one topic level in MQTT?
A+
B#
C*
D?
✗ Incorrect
'+' matches exactly one level; '#' matches multiple levels; '*' and '?' are not MQTT wildcards.
Explain how the '+' and '#' wildcards work in MQTT topic subscriptions and give an example of each.
Think about how you can listen to specific or broad topic patterns.
You got /3 concepts.
Describe why the '#' wildcard must be the last character in an MQTT subscription and what happens if it is not.
Consider how MQTT interprets topic hierarchies.
You got /3 concepts.
Practice
(1/5)
1. What does the MQTT wildcard + represent in topic subscriptions?
easy
A. It matches zero or more topic levels.
B. It matches exactly one topic level.
C. It matches the entire topic string.
D. It matches only the last topic level.
Solution
Step 1: Understand the + wildcard meaning
The + wildcard matches exactly one topic level in MQTT subscriptions.
Step 2: Compare with other wildcards
The # wildcard matches zero or more levels, so it is different from +.
Final Answer:
It matches exactly one topic level. -> Option B
Quick Check:
+ = one level [OK]
Hint: Remember: + means one level only [OK]
Common Mistakes:
Confusing + with # wildcard
Thinking + matches multiple levels
Assuming + matches zero levels
2. Which of the following is the correct MQTT subscription syntax to match all topics under home/kitchen including sub-levels?
easy
A. home/kitchen/#
B. home/+/kitchen
C. home/kitchen/+
D. home/#/kitchen
Solution
Step 1: Identify the wildcard for all sub-levels
The # wildcard matches all remaining topic levels, including zero or more sub-levels.
Step 2: Apply to the topic home/kitchen
Using home/kitchen/# subscribes to home/kitchen and any deeper topics like home/kitchen/temperature.
Final Answer:
home/kitchen/# -> Option A
Quick Check:
# matches all sub-levels [OK]
Hint: Use # to catch all subtopics under a path [OK]
Common Mistakes:
Using + instead of # for multiple levels
Placing # in the middle of the topic
Using invalid syntax like # in the middle
3. Given the subscription building/+/temperature, which of these topics will be matched?
medium
A. building/floor1/temperature
B. building/floor1/room1/temperature
C. building/temperature
D. building/floor1/humidity
Solution
Step 1: Understand the + wildcard position
The + wildcard matches exactly one topic level between building and temperature.
Step 2: Check each topic against the pattern
Topic building/floor1/temperature matches because floor1 fills the + wildcard. Others either have too many or too few levels or wrong last level.
Final Answer:
building/floor1/temperature -> Option A
Quick Check:
+ matches one level only [OK]
Hint: + matches exactly one level between slashes [OK]
Common Mistakes:
Matching topics with extra levels
Ignoring the exact position of +
Assuming + matches zero levels
4. You wrote the subscription sensor/#/temperature but it does not work. What is the problem?
medium
A. The subscription is missing a leading slash.
B. The + wildcard should be used instead of # here.
C. The topic levels are case sensitive and must be lowercase.
D. The # wildcard must be at the end of the topic filter.
Solution
Step 1: Recall the rule for # wildcard placement
The # wildcard must be the last character in the topic filter and can only appear once.
Step 2: Analyze the subscription sensor/#/temperature
Here, # is in the middle, which is invalid syntax and causes the subscription to fail.
Final Answer:
The # wildcard must be at the end of the topic filter. -> Option D
Quick Check:
# only at end [OK]
Hint: # must be last in topic filter [OK]
Common Mistakes:
Placing # in the middle of topic
Confusing + and # usage
Ignoring MQTT topic syntax rules
5. You want to subscribe to all topics under office but only one level deep, such as office/room1 and office/room2, but not office/room1/temperature. Which subscription should you use?
hard
A. office/+/+
B. office/#
C. office/+
D. office
Solution
Step 1: Understand the requirement for one level deep
You want to match topics exactly one level below office, like office/room1.
Step 2: Choose the correct wildcard
The + wildcard matches exactly one level, so office/+ matches office/room1 but not office/room1/temperature.
Final Answer:
office/+ -> Option C
Quick Check:
One level deep = use + wildcard [OK]
Hint: Use + for exactly one sub-level [OK]
Common Mistakes:
Using # which matches all levels
Using multiple + wildcards incorrectly
Not including any wildcard
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.