Home »
MCQs
FastAPI MCQs
FastAPI MCQs: This section contains multiple-choice questions on FastAPI. All MCQs have the correct answers and explanations. These MCQs will help students and professionals to test their skills and to enhance their knowledge of FastAPI.
List of FastAPI MCQs
1. FastAPI is a ____.
- Java Web framework
- Python Web framework
- Ruby Web framework
Answer: B) Python Web framework
Explanation:
FastAPI is a modern Python web framework.
Discuss this Question
2. FastAPI is built on top of ____.
- Flask
- Django
- Starlette
Answer: C) Starlette
Explanation:
FastAPI is built on top of Starlette.
Discuss this Question
3. When FastAPI was developed?
- Jan 2015
- Dec 2019
- Dec 2020
- Dec 2018
Answer: D) Dec 2018
Explanation:
FastAPI was created in December 2018 by Sebastian Ramirez.
Discuss this Question
4. Which of the following is used to install FastAPI?
- pip3 install fastapi
- pip3 install Starlette-fastapi
- pip3 install fastapi- Starlette
Answer: A) pip3 install fastapi
Explanation:
"Pip3 install fastapi" is used to install FastAPI.
Discuss this Question
5. Is it important to install Starlette and Pydantic libraries with FastAPI?
- Yes
- No
Answer: A) Yes
Explanation:
Since FastAPI relies on the Starlette and Pydantic libraries, these are also installed.
Discuss this Question
6. Does FastAPI come with any built-in server application?
- Yes
- No
Answer: B) No
Explanation:
FastAPI doesn't come with any built-in server application.
Discuss this Question
7. To launch the FastAPI application, you'll require an ASGI server named ____.
- Uvicorn
- Unicorn
- Umicorn
- Uxicorn
Answer: A) Uvicorn
Explanation:
To launch the FastAPI application, you'll require an ASGI server named uvicorn.
Discuss this Question
8. What is ASGI?
- Asynchronous System Gateway Interface
- Application Server Gateway Interface
- Application System Gateway Interface
- Asynchronous Server Gateway Interface
Answer: D) Asynchronous Server Gateway Interface
Explanation:
ASGI stands for Asynchronous Server Gateway Interface.
Discuss this Question
9. What is the full form of WSGI?
- Web Socket Gateway Interface
- Web Shift Gateway Interface
- Web Server Gateway Interface
Answer: C) Web Server Gateway Interface
Explanation:
WSGI stands for Web Server Gateway Interface.
Discuss this Question
10. A ____ is the section of the URL that comes after the initial '/'.
- Channel
- Unit
- Route
Answer: C) Route
Explanation:
A path or route is the section of the URL that comes after the initial '/'.
Discuss this Question
11. Which keyword in the function's definition tells FastAPI that it is to be run asynchronously?
- Asyn
- Async
- Asyncho
- All of the above
Answer: B) Async
Explanation:
The async keyword in the function's definition tells FastAPI that it is to be run asynchronously.
Discuss this Question
12. You must import the ____ in order to apply the validation requirements to a path argument.
- Parameter class
- Validate class
- Validation class
- Path class
Answer: D) Path class
Explanation:
You must import the Path class in order to apply the validation requirements to a path argument.
Discuss this Question
13. Which of the following is a Python data parsing and validation library.
- Pydantic
- PyOpe
- Schema
- Marshmello
Answer: A) Pydantic
Explanation:
Pydantic is a Python data parsing and validation library.
Discuss this Question
14. Pydantic will convert data types automatically whenever feasible.
- True
- False
Answer: A) True
Explanation:
Pydantic will convert data types automatically whenever feasible.
Discuss this Question
15. FastAPI sends a ____ response to the client by default
- HTML
- CSV
- JSON
Answer: C) JSON
Explanation:
FastAPI sends a JSON response to the client by default.
Discuss this Question
16. FastAPI has a which class to process the data received as a request by submitting an HTML form?
- HTML-FORM CLASS
- FORM CLASS
- HTML CLASS
Answer: B) FORM CLASS
Explanation:
FastAPI has a Form class to process the data received as a request by submitting an HTML form.
Discuss this Question
17. ____ is the process through which an item obtains other objects on which it depends.
- Refactoring dependency
- Dependency injection
- Coupling
Answer: B) Dependency injection
Explanation:
Dependency injection is the process through which an item obtains other objects on which it depends.
Discuss this Question
18. Which of the following is an advantage of dependency injection?
- Reuse shared functionality
- Share database connections
- Authentication and security requirements.
- All of the above
Answer: D) All of the above
Explanation:
Following are the advantages of dependency injection:
- Reuse shared functionality
- Share database connections
- Authentication and security requirements
Discuss this Question
19. What is the full form of CORS?
- Combine-Origin Resource Sharing
- Combine-Origin Resource System
- Cross-Origin Resource Sharing
Answer: C) Cross-Origin Resource Sharing
Explanation:
CORS stands for Cross-Origin Resource Sharing.
Discuss this Question
20. Which of the following statement is correct?
- Cross-Origin Resource Sharing (CORS) is a circumstance in which a backend program running on a different client browser attempt to connect with a frontend using HTML code, but the frontend is in a different "origin" than the backend.
- Cross-Origin Resource Sharing (CORS) is a circumstance in which a frontend program running on a one-client browser attempts to connect with a backend using JavaScript code, but the backend is in a different "origin" than the frontend.
Answer: B) Cross-Origin Resource Sharing (CORS) is a circumstance in which a frontend program running on a one-client browser attempts to connect with a backend using JavaScript code, but the backend is in a different "origin" than the frontend.
Explanation:
Statement B is correct, Cross-Origin Resource Sharing (CORS) is a circumstance in which a frontend program running on a one-client browser attempts to connect with a backend using JavaScript code, but the backend is in a different "origin" than the frontend.
Discuss this Question
21. ____ is a programming technique for converting data between incompatible type systems in object-oriented programming languages.
- OOP
- Functional programming
- ORM
- AOP
Answer: C) ORM
Explanation:
Object Relational Mapping is a programming technique for converting data between incompatible type systems in object-oriented programming languages.
Discuss this Question
22. Does FastAPI uses NoSQL DB?
- Yes
- No
Answer: A) Yes
Explanation:
FastAPI can also leverage NoSQL databases like MongoDB, Cassandra, CouchDB, and others as the backend for REST app CRUD operations.
Discuss this Question
23. A ____ is a persistent connection that allows bidirectional, full-duplex communication between a client and a server.
- Web Servlet
- WebSocket
- WebGL
Answer: B) WebSocket
Explanation:
A WebSocket is a persistent connection that allows bidirectional, full-duplex communication between a client and a server.
Discuss this Question
24. Which of the following is the HTTP's disadvantages?
- One of HTTP's disadvantages is that it is just a full-duplex or directional protocol.
- One of HTTP's disadvantages is that it is just a half-duplex or unidirectional protocol.
Answer: B) One of HTTP's disadvantages is that it is just a half-duplex or unidirectional protocol.
Explanation:
One of HTTP's disadvantages is that it is just a half-duplex or unidirectional protocol.
Discuss this Question
25. WebSockets are supported by FastAPI via the ____ class in the FastAPI module.
- Web class
- Sockets class
- WebGL class
- WebSockets class
Answer: D) WebSockets class
Explanation:
WebSockets are supported by FastAPI via the WebSocket class in the FastAPI module.
Discuss this Question
26. Does FastAPI supports asynchronous requests?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, FastAPI supports asynchronous requests, which can help your application run better.
Discuss this Question
27. Which of the following is a decorator used to specify a FastAPI route or endpoint? It is used to link a function to a certain HTTP request method (such as GET, POST, PUT, DELETE, and so on) and URL path.
- @app.router()
- @app.route_engine()
- @app.route()
Answer: C) @app.route()
Explanation:
@app.route() is a decorator used to specify a FastAPI route or endpoint. It is used to link a function to a certain HTTP request method (such as GET, POST, PUT, DELETE, and so on) and URL path.
Discuss this Question
28. Which of the following is a decorator for defining a route or endpoint that handles GET requests?
- @app.getter()
- @app.get()
- @app.get_request()
Answer: B) @app.get()
Explanation:
@app.get() is a decorator for defining a route or endpoint that handles GET requests.
Discuss this Question
29. To create a middleware you use which decorator?
- @app.middleware("http")
- @app.middle_route("http").
- @app.middleware_engine("http").
Answer: A) @app.middleware("http")
Explanation:
To create a middleware you use the decorator @app.middleware("http").
Discuss this Question
30. Which of the following refers to the addition of a complete "independent" application in a specified route, which subsequently handles all sub-paths?
- Casing
- Clamping
- Coupling
- Mounting
Answer: D) Mounting
Explanation:
"Mounting" refers to the addition of a complete "independent" application in a specified route, which subsequently handles all sub-paths.
Discuss this Question
31. Which of the following statement is True?
- A request body is data sent by the client to your API. A response body is the data your API sends to the client.
- A response body is data sent by the client to your API. A request body is the data your API sends to the client.
Answer: A) A request body is data sent by the client to your API. A response body is the data your API sends to the client.
Explanation:
Statement A is correct; a request body is data sent by the client to your API. A response body is the data your API sends to the client.
Discuss this Question
32. ____ is used to return HTTP replies with problems to the client.
- RouterException
- PathException
- HTTPException
Answer: C) HTTPException
Explanation:
HTTPException is used to return HTTP replies with problems to the client.
Discuss this Question
33. Which of the following middleware's are available in the FastAPI library?
- CORSMiddleware
- HTTPSRedirectMiddleware
- TrustedHostMiddleware
- GZipMiddleware
- All of the above
Answer: E) All of the above
Explanation:
Following are some of the middleware available in the FastAPI library:
- CORSMiddleware
- HTTPSRedirectMiddleware
- TrustedHostMiddleware
- GZipMiddleware
Discuss this Question
34. ____ are used to specify routes in FastAPI.
- Annotations
- Type Hinting
- Decorators
Answer: C) Decorators
Explanation:
Decorators are used to specify routes in FastAPI.
Discuss this Question
35. Can we use FastAPI to upload files?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, you can use FastAPI to upload files. There are several approaches, but the most typical is to utilize the FileUpload class.
Discuss this Question