IOT Questions and Answers – Publishing Messages to the Cloud

This set of IOT Questions and Answers for Entrance exams focuses on “Publishing Messages to the Cloud”.

1. Publishing messages is handled through ________ Class.
a) Client()
b) Server()
c) Publish()
d) Batch()
View Answer

Answer: a
Explanation: Publishing message is handled through the client class (aliased as google-cloud-pubsub-publisherclient).

2. client() class provides ________ to create topics.
a) Software
b) Classes
c) Methods
d) Batch
View Answer

Answer: c
Explanation: client() class provides the method to create topics. publish() method publishes messages to pub/sub. Publishing message is handled through the client class.

3. ________ method publishes messages to pub/sub.
a) Client()
b) Publish()
c) Server()
d) Batch()
View Answer

Answer: b
Explanation: While client() provides method to create topics, publish() method publishes messages to pub/sub.
advertisement
advertisement

4. How many arguments are accepted by publish()?
a) 5 arguments
b) 3 arguments
c) 1 argument
d) 2 arguments
View Answer

Answer: d
Explanation: publish() method accepts two positional arguments: the topic to publish to, and the body of the message.

5. Does publish() method accepts arbitrary arguments.
a) True
b) False
View Answer

Answer: a
Explanation: Publish() method also accepts arbitrary keyword arguments, which are passed along as attributes of the message.

6. The topic in the publish method is in which form?
a) Binomial form
b) Canonical form
c) Nominal form
d) Message form
View Answer

Answer: b
Explanation: The topic is passed along as a string; all topics have the canonical form of projects/{project_name}/topic/{topic_name}.

7. The message in pub/sub is an opaque blob of ________
a) Bits
b) Bytes
c) Word
d) Nibble
View Answer

Answer: b
Explanation: The message in pub/sub is an opaque blob of bytes, and as such, you must send a bytes object in python 3.
advertisement

8. ________ error will show if we try to send text string instead of bytes.
a) TypeError
b) Error
c) Linker error
d) Compiler error
View Answer

Answer: a
Explanation: If we send a text string the method will raise TypeError. TypeError will show if we try to send text string instead of bytes.

9. What do we call string in python 2?
a) Str
b) Unicode
c) Strs
d) Unicades
View Answer

Answer: b
Explanation: In python 3 the text string is called as str, and in python 2 it is called as unicode.
advertisement

10. When you publish a message ________ is automatically created?
a) Client
b) Server
c) Batch
d) Server
View Answer

Answer: c
Explanation: Whenever we publish a message, a batch is automatically created. This way, if you publish a large volume of messages, it reduces the number of requests made to the server.

11. When the batch is created, it begins a countdown that publishes the batch once sufficient time has elapsed.
a) True
b) False
View Answer

Answer: a
Explanation: When the batch is created, it begins a countdown that publishes the batch once sufficient time has elapsed.

12. What is the time elapsed after a batch is created?
a) 0.5 seconds
b) 0.05 seconds
c) 1.5 seconds
d) 1 second
View Answer

Answer: b
Explanation: When the batch is created, it begins a countdown that publishes the batch once sufficient time has elapsed by default it is 0.05 seconds.

13. Every call to publish() will return a class that conforms to the __________ interface.
a) Batch
b) Client
c) Server
d) Future
View Answer

Answer: d
Explanation: Every call to publish() will return a class that conforms to the future interface. You can use this to ensure that it is published.

Sanfoundry Global Education & Learning Series – IOT.

To practice all areas of IOT for Entrance exams, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.