REST (Representational State Transfer) is an architectural style for designing networked applications. It uses stateless communication and standard HTTP methods, such as GET, POST, PUT, and DELETE, for interacting with resources.
Which of the following is an example of a stateless web protocol?
A FTP
B HTTP
C SMTP
D WebSockets
HTTP (Hypertext Transfer Protocol) is a stateless protocol, meaning each request from a client to a server is treated independently, and no information is retained between requests. This simplifies communication but requires additional mechanisms like cookies for session management.
What does GraphQL allow developers to do?
A Create dynamic pages
B Send data to server
C Make API requests
D Query databases
GraphQL is a query language for APIs that allows developers to request specific data from a server, minimizing over-fetching. It enables more efficient and flexible data retrieval compared to traditional REST APIs.
Which web technology allows bidirectional communication between the client and server?
A REST API
B AJAX
C HTTP
D WebSockets
WebSockets enable full‐duplex, bidirectional communication between the client and server. This allows real‐time data exchange, making it suitable for applications like live chat, notifications, and online gaming.
Which of these is a core feature of RESTful APIs?
A Dynamic query handling
B Stateless communication
C Real-time data updates
D Data compression
One of the core principles of RESTful APIs is stateless communication, meaning each API request is independent and contains all the necessary information for processing. This simplifies scalability and maintenance.
What type of API allows clients to specify the exact data they need?
A SOAP
B REST
C JSON
D GraphQL
GraphQL allows clients to request exactly the data they need, avoiding over‐fetching. It enables more efficient communication by returning only the specified fields, unlike REST which may return unnecessary data.
Which of the following is commonly used to fetch data from APIs in JavaScript?
A request()
B fetch()
C post()
D select()
The fetch() method in JavaScript is used to make network requests to retrieve data from APIs. It returns a Promise, allowing developers to handle asynchronous operations easily, such as retrieving data from RESTful or GraphQL APIs.
Which of the following is a limitation of WebSockets?
A Stateless communication
B High server load
C Real-time data
D Complex syntax
WebSockets provide real-time bidirectional communication, but they can lead to high server load when managing multiple open connections simultaneously. This requires additional resources to maintain persistent connections for each client.
Which HTTP method is used to update an existing resource in a RESTful API?
A PUT
B GET
C DELETE
D POST
The PUT HTTP method is used to update an existing resource on the server. It replaces the current resource with the new data sent in the request body, ensuring that the resource is fully updated.
Which of the following is an advantage of using GraphQL over REST?
A Faster server response
B Flexibility in data retrieval
C Better data encryption
D Simpler to implement
GraphQL allows clients to request only the data they need, offering greater flexibility compared to REST. This minimizes over‐fetching and under‐fetching of data, improving both performance and efficiency in communication.
Which of the following is used for event-driven communication in real-time web applications?
A AJAX
B GraphQL
C HTTP
D WebSockets
WebSockets enable event‐driven, real‐time communication between the client and server. They are used in applications that require immediate updates, such as live chat systems, online gaming, and real‐time notifications.
What is the primary advantage of using RESTful APIs?
A Flexible data models
B Simple to integrate
C Real-time updates
D Optimized for scalability
RESTful APIs are widely used because of their simplicity and ease of integration with web applications. They rely on standard HTTP methods and can be consumed by various platforms and clients, making them highly versatile.
Which of these HTTP methods is idempotent?
A DELETE
B GET
C POST
D PUT
The GET method is idempotent, meaning that multiple identical requests will have the same effect as a single request. It is typically used for retrieving data without causing any side effects, such as altering server resources.
What does RESTful API rely on to handle requests and responses?
A SOAP
B HTTP
C WebSockets
D AJAX
RESTful APIs rely on the HTTP protocol for communication. They use standard HTTP methods like GET, POST, PUT, and DELETE to perform actions on resources, ensuring compatibility with the web’s infrastructure.
Which of the following describes the behavior of a stateless protocol like HTTP?
A Retains session data
B Stores client information
C Each request is independent
D Involves real-time updates
Stateless protocols, such as HTTP, treat each request independently. They do not retain any information about previous requests, meaning that each request from the client to the server must contain all the necessary information for processing.