CPA Web Development & APIs 2 — Questions and Answers
Question 1: What does API stand for?
- Automated Program Interface
- Application Processing Infrastructure
- Application Programming Interface (Correct answer)
- Advanced Protocol Integration
Correct answer: Application Programming Interface
API stands for Application Programming Interface, a set of rules and protocols that allows different software applications to communicate with each other.
Question 2: Which data format is most commonly used in modern REST APIs for data interchange?
- XML
- CSV
- JSON (Correct answer)
- YAML
Correct answer: JSON
JSON (JavaScript Object Notation) is the most widely used format in REST APIs due to its lightweight structure, human readability, and native support in JavaScript.
Question 3: What is OAuth primarily used for in web applications?
- Encrypting data in transit
- Authorization and delegated access to resources (Correct answer)
- Optimizing database queries
- Compressing HTTP responses
Correct answer: Authorization and delegated access to resources
OAuth is an open standard for authorization that allows users to grant third-party applications limited access to their resources without sharing credentials.
Question 4: What does an HTTP status code of 404 indicate?
- Internal server error
- Unauthorized access
- Redirect to another URL
- Resource not found (Correct answer)
Correct answer: Resource not found
HTTP 404 (Not Found) means the server could not locate the requested resource at the specified URL.
Question 5: What is the purpose of an API endpoint?
- To store data in a server database
- To monitor server performance metrics
- To define a specific URL where an API can be accessed (Correct answer)
- To encrypt API traffic
Correct answer: To define a specific URL where an API can be accessed
An API endpoint is a specific URL that represents a resource or function in an API, serving as the point of contact between an API and the client application.
Question 6: Which HTTP header is used to indicate the media type of the request or response body?
- Authorization
- Content-Type (Correct answer)
- Accept-Encoding
- Cache-Control
Correct answer: Content-Type
The Content-Type header specifies the media type (MIME type) of the body in an HTTP request or response, such as 'application/json' or 'text/html'.
Question 7: What does CORS stand for in web development?
- Content Optimization and Resource Sharing
- Cross-Origin Resource Sharing (Correct answer)
- Client-Oriented Request System
- Cached Output Rendering Service
Correct answer: Cross-Origin Resource Sharing
CORS (Cross-Origin Resource Sharing) is a browser security mechanism that controls how web pages can request resources from a different domain than the one that served the page.