PR_Midterm1
PR_Midterm1
PR_Midterm1
Physical Layer
Data Link Layer
Transport Layer
Session Layer
2. Which OSI model layer is the highest layer, used by applications to provide
services to end-users?
Presentation Layer
Application Layer
Data Link Layer
Network Layer
3. Which characteristics make SAX parsing efficient for handling large XML files?
Processes one element at a time
Loads the entire document into memory
Uses event-driven parsing
Relies on a tree-like structure
Avoids memory-intensive operations
4. The requests.get(url) function in Python returns which of the following on a
successful request?
A response object with status code 200
A POST request
JSON object by default
HTML content of the page if status is 200
5. The BeautifulSoup library in Python is primarily used to:
Parse HTML and XML documents
Create web pages
Test HTTP responses
Open web sockets
6. In Python, which library can be used to parse HTML content?
JSON
BeautifulSoup
SQLAlchemy
Django
7. In the client-server architecture, what role does the client typically perform?
Initiates a request for a resource or service
Provides responses to other clients
Acts as the user’s interface to access data or services
Manages data storage exclusively
8. Which layer of the OSI model is responsible for data encryption and decryption?
Data Link Layer
Network Layer
Presentation Layer
Application Layer
9. Which layer in the OSI model handles error correction and frame synchronization?
Physical Layer
Data Link Layer
Network Layer
Application Layer
10. Which OSI model layer handles bit-level transmission between devices?
Physical Layer
Data Link Layer
Network Layer
Application Layer
11. What are advantages of using the SAX parser for XML?
Memory-efficient and suitable for large documents
Allows modifications to XML data as it’s being read
Event-driven approach, triggering events as elements are read
Builds an in-memory tree structure for easy navigation
Efficient for reading large XML files in a sequential manner
Only compatible with JavaScript-based XML processing
12. Why is data validation important before serialization?
It ensures data integrity
It ignores business logic
It prevents injection attacks
It slows down processing significantly
It supports data consistency
13. What are the steps to use Protocol Buffers in Python for data serialization?
Define a .proto file with message definitions
Use the ParseFromString() method to serialize data
Generate Python code with protoc
Create the schema in XML
Use SerializeToString() to serialize data
14. Which serialization formats are commonly used for data interchange between
systems?
JSON (JavaScript Object Notation)
XML (eXtensible Markup Language)
Protocol Buffers (ProtoBuf)
CSV (Comma-Separated Values)
SQL
Markdown (MD)
None of the above
All of the above
15. What is the purpose of signal.signal(signal.SIGINT, signal_handler) in Python
code?
To handle interruption signals like Ctrl+C for graceful shutdown
To increase server speed
To automatically restart the server on error
To register IP addresses for connections
16. In the OSI model, which layer is responsible for routing packets between
devices?
Physical Layer
Data Link Layer
Network Layer
Transport Layer
17. Which OSI layer is responsible for establishing, managing, and terminating
sessions between applications?
Network Layer
Session Layer
Presentation Layer
Application Layer
18. The PUT method is considered idempotent. This means:
Multiple requests yield the same result as a single request
It changes each time it is executed
It only applies to DELETE requests
Results vary based on the request timing
19. What is a characteristic of the client-server architecture?
Scalability
Lack of resource sharing
Data stored only on clients
Request-Response Model
20. Web crawlers should respect the file robots.txt to:
Adhere to a site’s permissions for crawling
Increase crawling speed
Collect maximum data from the website
Avoid potential legal issues and restrictions
21. What are the main functions used to modify XML content using a DOM parser in
Python?
createElement()
createTextNode()
parseFile()
setAttribute()
processNode()
22. What would be an appropriate response header to indicate an HTTP response is
successful?
HTTP/1.1 404 Not Found
HTTP/1.1 200 OK
HTTP/1.1 500 Internal Server Error
HTTP/1.1 301 Moved Permanently
23. What is the correct command to kill a process that is using port 8080 in Unix?
kill -9
lsof -i :8080 | awk '{print $2}' | xargs kill
lsof -t :8080
shutdown -8080
24. What are key benefits of using Protocol Buffers (Protobuf) over text-based data
formats?
Compact, binary-encoded data
Language-agnostic schema
Loads the entire document into memory
Backward and forward compatibility
Designed exclusively for XML parsing
25. What is the purpose of the command client_socket, client_address =
server_socket.accept()?
To accept an incoming client connection
To bind the server to the client
To close a client connection
To initiate a new socket
26. Which HTTP method is not idempotent, meaning the same request can have
different outcomes if repeated?
POST
GET
PUT
DELETE
27. In the OSI model, which layer deals with the end-to-end delivery of messages
between two devices?
Data Link Layer
Network Layer
Transport Layer
Session Layer
28. What does server_socket.listen(5) do in the Python web server example?
It allows up to 5 simultaneous connections to be queued
It limits connections to a single client
It sets the server port to 5
It enables automatic retries on connection failure
29. Which HTTP method is used to submit data for processing, often resulting in the
creation of a new resource?
GET
POST
DELETE
PUT
30. Which tool is often used to simulate a GET request manually in the terminal?
cURL
Telnet
Wget
SSH
31. Which of the following describe the structure and syntax of an XML document?
Contains a root element that encapsulates all other elements
Uses angle brackets to enclose tags
Contains key-value pairs similar to JSON syntax
Elements can have attributes to store additional information
Structured hierarchically with nested elements
All data is stored as plain text within curly braces
32. Which practices improve Protobuf schema design for evolving systems?
Versioning serialized data
Marking fields as optional
Tight coupling of schema and code
Using extensible enums and unions
Using version identifiers only in non-critical fields
Documenting schema changes over time
33. Which keywords or syntax elements are essential in a Protobuf .proto file?
syntax = "proto3";
repeated for multiple instances of a type
@XMLRoot
message to define data structures
<field>
34. Which HTTP header signals that a connection should be closed after receiving a
response?
Connection: close
Host: disconnect
End-session
Connection: end-session-and-disconnect
35. Which Protobuf features allow it to evolve over time without breaking existing
clients?
Adding new fields without breaking old clients
Removing fields completely from the schema
Reserving field numbers to prevent reuse
Using smaller field numbers for less common fields
Retaining backward and forward compatibility
36. Which line in the web server code sends a response to the client?
client_socket.send(response.encode('utf-8'))
client_socket.recv(1024)
server_socket.bind((HOST, PORT))
server_socket.listen(5)
37. In the OSI model, which layer is responsible for addressing and routing
packets?
Physical Layer
Data Link Layer
Network Layer
Transport Layer
38. What is the primary purpose of the OSI Model in networking?
To define standard protocols for email
To provide a framework for understanding and designing network protocols
To enforce security protocols across networks
To create a web server framework
39. At which layer of the OSI model does TCP (Transmission Control Protocol)
operate?
Network Layer
Transport Layer
Data Link Layer
Session Layer
40. Which best practices improve data validation before serialization?
Define clear data validation rules
Log validation errors and successes
Use tightly coupled schema and code
Include business logic validation
Validate only after serialization
Avoid automated testing
41. In Protobuf, which types can be used as field types in a .proto file?
int32, int64, float
bool, string, bytes
Custom message types
Arrays without repeated keyword
DataFrames
Enums
42. What are key practices to ensure backward and forward compatibility in
serialization?
Ignore unknown fields when deserializing
Use a designated null value for missing data
Avoid version identifiers in schemas
Add default values for new fields
Avoid schema documentation
Use regression testing to verify compatibility
43. Which protocol is commonly used for communication between web browsers and web
servers?
HTTP
SSH
SMTP
Telnet
44. Which of the following HTTP methods is typically used to delete a resource from
the server?
GET
PUT
DELETE
CONNECT
45. What is the main function of the command lsof -i :8080 in a Unix environment?
To list all open files on port 8080
To list all closed files on port 8080
To display HTTP server requests
To shut down a server on port 8080
46. Which of the following are characteristics of JSON?
Human-readable format
Based on the structure of HTML
Lightweight and efficient for data transmission
Only used with JavaScript-based systems
Language-agnostic and compatible with multiple programming languages
Only supports numeric and string data types
47. In a GET request, what is specified in the request line?
HTTP method, path, and version
Resource location only
Only the server’s address
Request header information
48. What are common use cases for Protocol Buffers (Protobuf)?
Web APIs with gRPC
IoT Devices
Managing SQL databases
Image Processing
High-Performance Applications
49. Which of the following is a key component of the client-server architecture?
Client
DNS
Server
FTP
50. What are the main reasons for using serialization in network applications?
To prepare data for transmission over networks
To convert data into a format that can be easily stored or shared
To change the structure of data without affecting its content
To make data compatible across different systems and platforms
To replace the need for databases in data storage
To increase the size of data for easier parsing