This set of IOT Multiple Choice Questions & Answers (MCQs) focuses on “Publishing Messages to the Cloud”.
1. Publishing messages is handled through ________ Class.
a) Client()
b) Server()
c) Publish()
d) Batch()
View Answer
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
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
Explanation: While client() provides method to create topics, publish() method publishes messages to pub/sub.
4. How many arguments are accepted by publish()?
a) 5 arguments
b) 3 arguments
c) 1 argument
d) 2 arguments
View Answer
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
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
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
Explanation: The message in pub/sub is an opaque blob of bytes, and as such, you must send a bytes object in python 3.
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
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
Explanation: In python 3 the text string is called as str, and in python 2 it is called as unicode.
10. When you publish a message ________ is automatically created?
a) Client
b) Server
c) Batch
d) Server
View Answer
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
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
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
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, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Check Programming Books
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Check IOT Books