NEW
Font size
WorksheetsLong Quiz | INFOT 1 – Integrative Programming and Technologies
Total questions: 40
Worksheet time: 30mins
Direction: Read the questions carefully. Write the letter that corresponds to the correct answer. What is the primary characteristic of "tight coupling" in software integration?
Components are independent and communicate via a message broker.
Two components are highly dependent on each other, with detailed knowledge of each other's interface and location.
A single, giant application handles all tasks.
Communication follows a "fire-and-forget" principle.
What is a major drawback of a tightly coupled system, described as "brittleness"?
The system is flexible and can easily add new services.
The system performs faster because services communicate directly.
If one service fails, the entire chain of services that depend on it also fails.
It only requires scaling the specific service that is a bottleneck.
What is the core idea behind asynchronous messaging?
A service makes a call and must wait for a direct response before continuing its own work.
A service announces an event and can immediately respond to the user without waiting for other services to complete their tasks.
All services in a system are combined into a single monolithic application.
Services have detailed knowledge of each other's inner workings to ensure proper communication.
How is "loose coupling" defined?
Two components are highly dependent on each other, similar to two people holding hands.
Components are independent and interact through a well-defined interface without knowledge of each other's existence or internal workings.
A system where a change in one service often requires changes in all the services that call it.
A system where an order service makes a direct HTTP call to a payment service and waits for a response.
In the restaurant kitchen analogy, what does the central ticket queue represent?
The Producer/Publisher
The Consumer/Subscriber
The Message Broker
The "order placed" message
What is the correct pip command to install the Paho-MQTT library?
pip install mqtt
pip get paho-mqtt
pip install paho-mqtt
python -m install paho
The Paho-MQTT library's mental model is built around which two key concepts?
The Broker and the Topic
The Client Object and Callbacks
Publishers and Subscribers
loop_start() and loop_stop()
In a Paho-MQTT subscriber script, what is the primary purpose of the on_message callback function?
To check if the connection to the broker was successful.
To run when a message has been successfully published to the broker.
To start the network loop in a background thread.
To run when a message has been received from the broker on a subscribed topic.
What is the function of the client.loop_start() method?
It starts a while True: loop to keep the main script alive.
It starts a new background thread to automatically handle all network traffic.
It publishes a message in a continuous loop.
It immediately stops the network connection.
What happens if a second client connects to a broker with the same Client ID as an existing client?
Both clients will receive all messages.
The second client's connection will be rejected.
The first client gets kicked off the broker.
The broker will automatically assign a new unique ID to the second client.
What does a Quality of Service (QoS) level of 1 guarantee?
The message is delivered "at most once" (fire and forget).
The message is delivered "exactly once".
The message is delivered "at least once".
The message is encrypted during delivery.
What is the purpose of using the on_publish callback in a publisher script?
To receive incoming messages from the broker.
To subscribe to a topic after connecting.
To get confirmation that the broker has received the message.
To decode the payload of a sent message.
Which callback is essential for a subscriber but is generally not needed for a simple publisher that only sends messages?
on_connect
on_message
on_publish
on_disconnect
Our lesson describes MQTT as asynchronous. How does the Paho library handle this?
By using a while True: loop to constantly ask the broker if there are new messages.
By defining callback functions that the client runs when specific events occur.
By using the client.connect() method, which blocks until a message is received.
By requiring the user to manually check for messages with a client.check_message() function.
What is the recommended best practice for a "clean disconnect" from the broker?
Simply ending the script, allowing the broker to time out the connection.
Calling client.disconnect() before client.loop_stop().
Calling client.loop_stop() and then client.disconnect() to gracefully leave.
Sending a final message with the topic "disconnect/me".
What primary problem did XML emerge to solve in the 1990s?
The need for a more dynamic web page layout language than HTML.
The inability of different systems to communicate effectively due to proprietary data formats.
The lack of a standardized way to query databases.
The slow speed of data transmission over networks.
Which of the following is a key characteristic of XML?
It has a fixed set of tags, similar to HTML.
It is a binary format that is only machine-readable.
It is extensible, meaning you can define your own tags specific to your domain.
It is a programming language for creating applications.
What does it mean for XML to be "self-describing"?
The document must include a detailed comment section explaining its purpose.
The structure and tags themselves reveal the meaning of the data.
It can be automatically translated into any human language.
It contains executable code that describes how the data should be processed.
What is the purpose of the XML Declaration ?
To define the single root element of the document.
To act as a comment that is ignored by the parser.
To tell the parser how to interpret the document, including version and character encoding.
To import external schema files for validation.
Which of the following is a fundamental rule for an XML document to be "well-formed"?
It must contain at least one attribute.
All text content must be enclosed in CDATA sections.
All tags must be in lowercase.
It must have a single root element.
Which of the following lines of XML demonstrates improperly nested tags?
This is bold text.
This text is bold and italic.
Why is the following XML snippet NOT well-formed:
The element name is not a valid standard XML tag.
The opening tag
The value "Rolen" should not be capitalized.
The root element is missing an id attribute.
According to the rules of well-formedness, what is wrong with this XML element:
The id value is numeric and should be a string.
The attribute value is not enclosed in quotes.
The tag name student should be capitalized.
The element contains no text content.
How must the special characters < and & be represented in XML content to ensure it is well-formed?
They must be replaced with < and & respectively.
They are allowed as-is, and the parser will handle them automatically.
They must be enclosed in double quotes.
They must be removed from the document entirely.
In the XML tree structure, what type of node does the content "Alice" in
Element Node
Attribute Node
Text Node
Document Node
What is the Document Object Model (DOM)?
A file format for storing XML data efficiently on disk.
A W3C standard programming interface that represents an XML document as a manipulable tree of objects in memory.
A Python-specific library for creating XML files from scratch.
A network protocol for transferring XML documents.
Which of the following is a key characteristic of DOM parsing?
It processes the XML file sequentially and cannot go back to a previous node.
It has very low memory usage, regardless of file size.
It allows for random access, meaning any part of the document can be accessed directly.
It is a read-only model and cannot be used to modify the XML document.
What is the primary drawback of using the DOM parsing model?
It cannot handle XML documents with attributes.
It can only access nodes in the order they appear in the file.
It consumes significant memory because the entire document is loaded into RAM.
It is not part of the Python standard library and requires a separate installation.
Approximately how much memory does a DOM tree use compared to the original XML file size?
The same amount as the file size.
About half the file size.
3–5 times the file size.
10 times the file size.
Which Python module is used in DOM parsing, and why is it recommended for most tasks?
lxml, because it is the fastest parser available.
xml.dom.full, because it implements the complete W3C standard.
xml.dom.minidom, because it is a lightweight, simpler implementation included in the standard library.
ElementTree, because it is the newest and most modern API.
After parsing an XML file with minidom.parse(), what is the type of the main object you get back?
xml.dom.minidom.Element
xml.dom.minidom.Document
xml.dom.minidom.NodeList
xml.dom.minidom.Text
How do you get the actual root element (e.g.,
dom.rootNode
dom.getFirst()
dom.documentElement
dom.childNodes[0]
The childNodes property of an element node contains:
Only other element nodes.
Only text nodes.
A NodeList of mixed node types including elements and text.
Only attribute nodes.
In the xml.dom.Node class, what is the constant used to identify an element node?
Node.ELEMENT
Node.ELEMENT_NODE
Node.TAG_NODE
Node.NODE_ELEMENT
What does the method getElementsByTagName('student') return?
The first student element found in the document.
A list of all student elements in the document.
A dictionary of all student elements, keyed by their ID.
A string containing the text of all student elements.
What is the primary limitation of DOM parsing that SAX is designed to solve?
DOM is read-only and cannot modify XML documents.
DOM has high memory consumption because it loads the entire document into a tree structure.
DOM can only process XML files sequentially.
DOM parsers are not included in standard Python libraries.
How does the SAX model process an XML document?
It builds a complete in-memory tree of objects for random access.
It loads the entire file into a single string for text processing.
It processes the XML as a stream, generating events for XML constructs as they are encountered.
It converts the XML into a relational database table.
Which analogy best describes the SAX parsing model?
Taking a photo of a document to examine the whole page at once.
Building a complete scale model of a building before analyzing it.
Reading a book aloud, reacting to each sentence as you encounter it without memorizing the whole book.
Creating a detailed index for a book, allowing you to jump to any page.
In Python's xml.sax module, what is the purpose of the ContentHandler class?
It is the main parser object that reads the XML file.
It is a base class that you extend to create callback methods for handling parsing events.
It is a utility for validating the XML against a schema.
It is a class that holds the entire parsed XML tree in memory.
Which ContentHandler method is called when the parser encounters an opening tag like
startDocument()
characters()
startElement()
endElement()
