0% found this document useful (0 votes)
2 views13 pages

API and Design Pattern

The document contains a comprehensive list of 50 API-related questions and answers, covering fundamental concepts such as what an API is, RESTful APIs, HTTP methods, and status codes. Additionally, it includes 50 design pattern questions and answers, explaining various design patterns, their categories, and specific patterns like Singleton, Factory Method, and Adapter. This resource serves as a quick reference for understanding APIs and design patterns in software development.

Uploaded by

21201144
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views13 pages

API and Design Pattern

The document contains a comprehensive list of 50 API-related questions and answers, covering fundamental concepts such as what an API is, RESTful APIs, HTTP methods, and status codes. Additionally, it includes 50 design pattern questions and answers, explaining various design patterns, their categories, and specific patterns like Singleton, Factory Method, and Adapter. This resource serves as a quick reference for understanding APIs and design patterns in software development.

Uploaded by

21201144
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

50 API Short Q&A

1. Q: What is an API? A: Application Programming Interface — a set of rules


that lets different software applications communicate with each other.
2. Q: What does REST stand for? A: Representational State Transfer.
3. Q: What is a RESTful API? A: An API that follows REST architectural
principles using standard HTTP methods.
4. Q: What is an endpoint? A: A specific URL where an API can be accessed
to perform an operation.
5. Q: What is HTTP? A: HyperText Transfer Protocol, used for communication
between clients and servers.
6. Q: What is the GET method used for? A: Retrieving data from a server
without modifying it.
7. Q: What is the POST method used for? A: Sending data to the server to
create a new resource.
8. Q: What is the PUT method used for? A: Updating an existing resource
completely.
9. Q: What is the PATCH method used for? A: Partially updating an existing
resource.
10.Q: What is the DELETE method used for? A: Removing a resource from the
server.
11.Q: What is a status code? A: A three-digit number returned by the server
indicating the result of a request.
12.Q: What does status code 200 mean? A: The request was successful.
13.Q: What does status code 201 mean? A: A resource was successfully
created.
14.Q: What does status code 400 mean? A: Bad request — the client sent
invalid data.
15.Q: What does status code 401 mean? A: Unauthorized — authentication is
required or failed.
16.Q: What does status code 403 mean? A: Forbidden — the client is
authenticated but not allowed access.
17.Q: What does status code 404 mean? A: The requested resource was not
found.
18.Q: What does status code 500 mean? A: Internal server error.
19.Q: What is JSON? A: JavaScript Object Notation, a lightweight data-
interchange format.
20.Q: What is XML? A: Extensible Markup Language, a markup format used
for structured data exchange.
21.Q: What is an API key? A: A unique code used to identify and authenticate a
client calling an API.
22.Q: What is authentication in APIs? A: The process of verifying the identity
of a client making a request.
23.Q: What is authorization in APIs? A: The process of determining what an
authenticated client is allowed to do.
24.Q: What is OAuth? A: An open standard protocol for token-based
authorization.
25.Q: What is a bearer token? A: A security token included in request headers
to authenticate API calls.
26.Q: What is JWT? A: JSON Web Token, a compact token format used to
securely transmit claims between parties.
27.Q: What is an API request header? A: Metadata sent with a request, such as
content type or authorization info.
28.Q: What is a request body? A: The data sent by the client to the server,
typically in POST or PUT requests.
29.Q: What is a query parameter? A: A key-value pair added to a URL to filter
or modify a request.
30.Q: What is a path parameter? A: A variable part of the URL path used to
identify a specific resource.
31.Q: What is rate limiting? A: Restricting the number of API requests a client
can make in a given time period.
32.Q: What is API versioning? A: The practice of managing changes to an API
by maintaining different versions.
33.Q: What is a webhook? A: A mechanism where a server sends real-time data
to another application when an event occurs.
34.Q: What is the difference between webhook and API? A: An API is called
by the client to request data; a webhook is triggered by the server to push
data.
35.Q: What is SOAP? A: Simple Object Access Protocol, a protocol for
exchanging structured information using XML.
36.Q: What is the difference between REST and SOAP? A: REST is
lightweight and uses standard HTTP methods with flexible data formats;
SOAP is a stricter protocol using XML only.
37.Q: What is GraphQL? A: A query language for APIs that lets clients request
exactly the data they need.
38.Q: How does GraphQL differ from REST? A: GraphQL uses a single
endpoint with flexible queries, while REST uses multiple endpoints with
fixed data structures.
39.Q: What is idempotency in APIs? A: A property where making the same
request multiple times produces the same result.
40.Q: Is the GET method idempotent? A: Yes.
41.Q: Is the POST method idempotent? A: No.
42.Q: What is CORS? A: Cross-Origin Resource Sharing, a mechanism
allowing restricted resources to be requested from another domain.
43.Q: What is API documentation? A: A guide describing how to use an API,
including endpoints, parameters, and responses.
44.Q: What is Swagger/OpenAPI? A: A specification and toolset used to
design, document, and test APIs.
45.Q: What is a payload? A: The actual data sent in the body of a request or
response.
46.Q: What is throttling in APIs? A: Controlling the rate of requests to prevent
overload on the server.
47.Q: What is an API gateway? A: A server that acts as a single entry point for
managing, routing, and securing API requests.
48.Q: What is caching in APIs? A: Storing responses temporarily to reduce
server load and improve performance for repeated requests.
49.Q: What is a microservice API? A: An API that exposes functionality of an
individual microservice within a larger system.
50.Q: What is API testing? A: The process of verifying that an API functions
correctly, securely, and performs as expected.

50 API Interview Questions and Short Answers

1. What is an API?
Answer: Application Programming Interface.
2. What is the purpose of an API?
Answer: To allow communication between applications.
3. What does API stand for?
Answer: Application Programming Interface.
4. What is a REST API?
Answer: An API based on REST architecture.
5. What does REST stand for?
Answer: Representational State Transfer.
6. What protocol do REST APIs commonly use?
Answer: HTTP.
7. What is an endpoint?
Answer: A specific API URL.
8. What is a request?
Answer: A call sent to an API.
9. What is a response?
Answer: Data returned by an API.
[Link] is JSON?
Answer: JavaScript Object Notation.
[Link] is JSON used in APIs?
Answer: To exchange data.
[Link] is XML?
Answer: Extensible Markup Language.
[Link] format is more common in REST APIs?
Answer: JSON.
[Link] is the GET method used for?
Answer: Retrieving data.
[Link] is the POST method used for?
Answer: Creating data.
[Link] is the PUT method used for?
Answer: Updating a resource.
[Link] is the PATCH method used for?
Answer: Partially updating a resource.
[Link] is the DELETE method used for?
Answer: Deleting data.
[Link] does HTTP stand for?
Answer: HyperText Transfer Protocol.
[Link] is HTTPS?
Answer: Secure HTTP.
[Link] is an HTTP status code?
Answer: A code indicating request status.
[Link] does status code 200 mean?
Answer: OK.
[Link] does status code 201 mean?
Answer: Created.
[Link] does status code 204 mean?
Answer: No Content.
[Link] does status code 400 mean?
Answer: Bad Request.
[Link] does status code 401 mean?
Answer: Unauthorized.
[Link] does status code 403 mean?
Answer: Forbidden.
[Link] does status code 404 mean?
Answer: Not Found.
[Link] does status code 500 mean?
Answer: Internal Server Error.
[Link] is authentication?
Answer: Verifying user identity.
[Link] is authorization?
Answer: Granting access permissions.
[Link] is an API key?
Answer: A unique key for API access.
[Link] is a Bearer Token?
Answer: A token used for authentication.
[Link] is OAuth?
Answer: An authorization framework.
[Link] is JWT?
Answer: JSON Web Token.
[Link] is a request header?
Answer: Metadata sent with a request.
[Link] is a request body?
Answer: Data sent to the API.
[Link] is a query parameter?
Answer: Data passed in the URL.
[Link] is a path parameter?
Answer: A value in the endpoint path.
[Link] is API documentation?
Answer: Instructions for using an API.
[Link] is Postman?
Answer: An API testing tool.
[Link] is Swagger?
Answer: An API documentation tool.
[Link] is OpenAPI?
Answer: A specification for REST APIs.
[Link] is rate limiting?
Answer: Restricting the number of requests.
[Link] is CORS?
Answer: Cross-Origin Resource Sharing.
[Link] is an idempotent API method?
Answer: A method with the same result after repeated requests.
[Link] HTTP methods are idempotent?
Answer: GET, PUT, DELETE.
[Link] is versioning in APIs?
Answer: Managing different API versions.
[Link] is GraphQL?
Answer: A query language for APIs.
[Link] are APIs important?
Answer: They enable systems and applications to communicate and share
data efficiently.
50 Design Pattern Interview Questions and Short Answers

1. What is a design pattern?


Answer: A reusable solution to common software design problems.
2. Why are design patterns used?
Answer: To create maintainable and reusable code.
3. Who introduced design patterns?
Answer: Gang of Four (GoF).
4. How many GoF design patterns are there?
Answer: 23.
5. What are the three categories of design patterns?
Answer: Creational, Structural, and Behavioral.
6. What is a Creational pattern?
Answer: A pattern for object creation.
7. What is a Structural pattern?
Answer: A pattern for organizing classes and objects.
8. What is a Behavioral pattern?
Answer: A pattern for communication between objects.
9. What is the Singleton pattern?
Answer: Ensures only one instance of a class exists.
[Link] is Singleton used?
Answer: When only one shared instance is needed.
[Link] is the Factory Method pattern?
Answer: Creates objects without exposing creation logic.
[Link] is the Abstract Factory pattern?
Answer: Creates families of related objects.
[Link] is the Builder pattern?
Answer: Constructs complex objects step by step.
[Link] is the Prototype pattern?
Answer: Creates objects by cloning existing ones.
[Link] is the Adapter pattern?
Answer: Makes incompatible interfaces work together.
[Link] is the Bridge pattern?
Answer: Separates abstraction from implementation.
[Link] is the Composite pattern?
Answer: Treats individual and grouped objects uniformly.
[Link] is the Decorator pattern?
Answer: Adds behavior to objects dynamically.
[Link] is the Facade pattern?
Answer: Provides a simplified interface to a subsystem.
[Link] is the Flyweight pattern?
Answer: Reduces memory by sharing objects.
[Link] is the Proxy pattern?
Answer: Controls access to another object.
[Link] is the Chain of Responsibility pattern?
Answer: Passes requests through multiple handlers.
[Link] is the Command pattern?
Answer: Encapsulates a request as an object.
[Link] is the Interpreter pattern?
Answer: Defines grammar for a language.
[Link] is the Iterator pattern?
Answer: Traverses elements of a collection.
[Link] is the Mediator pattern?
Answer: Centralizes communication between objects.
[Link] is the Memento pattern?
Answer: Saves and restores object state.
[Link] is the Observer pattern?
Answer: Notifies dependent objects of changes.
[Link] is the State pattern?
Answer: Changes behavior based on object state.
[Link] is the Strategy pattern?
Answer: Encapsulates interchangeable algorithms.
[Link] is the Template Method pattern?
Answer: Defines an algorithm skeleton.
[Link] is the Visitor pattern?
Answer: Adds operations without changing classes.
[Link] is the MVC pattern?
Answer: Model-View-Controller architecture.
[Link] does Model represent?
Answer: Data and business logic.
[Link] does View represent?
Answer: User interface.
[Link] does Controller represent?
Answer: Handles user input and requests.
[Link] pattern improves code reuse?
Answer: Strategy pattern.
[Link] pattern supports event handling?
Answer: Observer pattern.
[Link] pattern is commonly used for logging?
Answer: Singleton pattern.
[Link] pattern simplifies complex systems?
Answer: Facade pattern.
[Link] pattern wraps existing objects?
Answer: Decorator pattern.
[Link] pattern reduces object creation cost?
Answer: Flyweight pattern.
[Link] pattern creates objects through cloning?
Answer: Prototype pattern.
[Link] pattern provides flexible object creation?
Answer: Factory Method.
[Link] pattern separates object construction from representation?
Answer: Builder pattern.
[Link] is loose coupling?
Answer: Minimizing dependencies between classes.
[Link] is high cohesion?
Answer: Keeping related functionality together.
[Link] design principle is "Program to an interface"?
Answer: Depend on abstractions, not implementations.
[Link] is SOLID?
Answer: Five object-oriented design principles.
[Link] are design patterns important?
Answer: They improve code quality, maintainability, and reusability.

50 Design Pattern Short Q&A

1. Q: What is a design pattern? A: A reusable, proven solution to a common


software design problem.
2. Q: How many main categories of design patterns are there? A: Three —
Creational, Structural, and Behavioral.
3. Q: What are creational design patterns? A: Patterns that deal with object
creation mechanisms.
4. Q: What are structural design patterns? A: Patterns that deal with the
composition of classes and objects.
5. Q: What are behavioral design patterns? A: Patterns that deal with
communication and responsibility between objects.
6. Q: What is the Singleton pattern? A: Ensures a class has only one instance
and provides a global point of access to it.
7. Q: When would you use a Singleton? A: When exactly one object is needed
to coordinate actions, like a configuration manager or logger.
8. Q: What is a drawback of Singleton? A: It can introduce global state,
making testing and concurrency harder.
9. Q: What is the Factory Method pattern? A: Defines an interface for creating
an object but lets subclasses decide which class to instantiate.
10.Q: What is the Abstract Factory pattern? A: Provides an interface for
creating families of related objects without specifying concrete classes.
11.Q: How does Abstract Factory differ from Factory Method? A: Factory
Method creates one product via inheritance; Abstract Factory creates
families of related products via composition.
12.Q: What is the Builder pattern? A: Separates the construction of a complex
object from its representation, allowing step-by-step creation.
13.Q: When is the Builder pattern useful? A: When an object requires many
optional parameters or a complex construction process.
14.Q: What is the Prototype pattern? A: Creates new objects by copying an
existing object (cloning) rather than creating from scratch.
15.Q: What is the Adapter pattern? A: Converts the interface of a class into
another interface clients expect.
16.Q: When would you use an Adapter? A: When integrating incompatible
interfaces, such as a legacy system with a new one.
17.Q: What is the Bridge pattern? A: Decouples an abstraction from its
implementation so both can vary independently.
18.Q: What is the Composite pattern? A: Composes objects into tree structures
to represent part-whole hierarchies, treating individual and composite
objects uniformly.
19.Q: What is the Decorator pattern? A: Adds new behavior to an object
dynamically without altering its structure.
20.Q: How does Decorator differ from inheritance? A: Decorator adds behavior
at runtime via composition, while inheritance adds behavior at compile time
via subclassing.
21.Q: What is the Facade pattern? A: Provides a simplified, unified interface to
a complex subsystem.
22.Q: What is the Flyweight pattern? A: Reduces memory usage by sharing
common parts of state between multiple objects.
23.Q: What is the Proxy pattern? A: Provides a placeholder or surrogate for
another object to control access to it.
24.Q: What are common types of Proxy? A: Virtual proxy, remote proxy,
protection proxy, and caching proxy.
25.Q: What is the Observer pattern? A: Defines a one-to-many dependency so
that when one object changes state, all its dependents are notified
automatically.
26.Q: Where is the Observer pattern commonly used? A: In event handling
systems, such as GUI listeners or pub-sub messaging.
27.Q: What is the Strategy pattern? A: Defines a family of algorithms,
encapsulates each one, and makes them interchangeable at runtime.
28.Q: How does Strategy differ from simple if-else logic? A: Strategy
encapsulates each algorithm in its own class, promoting flexibility and
adherence to the Open/Closed Principle.
29.Q: What is the Command pattern? A: Encapsulates a request as an object,
allowing parameterization and queuing of requests.
30.Q: What is a use case for the Command pattern? A: Implementing undo/redo
functionality or task queues.
31.Q: What is the State pattern? A: Allows an object to change its behavior
when its internal state changes, appearing as if it changed class.
32.Q: What is the Template Method pattern? A: Defines the skeleton of an
algorithm in a method, letting subclasses override specific steps without
changing the structure.
33.Q: What is the Chain of Responsibility pattern? A: Passes a request along a
chain of handlers until one of them handles it.
34.Q: What is a real-world example of Chain of Responsibility? A: Middleware
in web frameworks or approval workflows with multiple levels.
35.Q: What is the Mediator pattern? A: Defines an object that encapsulates how
a set of objects interact, reducing direct dependencies between them.
36.Q: What is the Memento pattern? A: Captures and restores an object's
internal state without violating encapsulation.
37.Q: What is a common use of Memento? A: Implementing undo functionality
in applications.
38.Q: What is the Visitor pattern? A: Lets you define a new operation on a set
of objects without changing their classes.
39.Q: What is the Iterator pattern? A: Provides a way to access elements of a
collection sequentially without exposing its underlying structure.
40.Q: What is the Interpreter pattern? A: Defines a grammar for a language and
an interpreter to process sentences in that grammar.
41.Q: What problem does the MVC pattern solve? A: It separates an application
into Model, View, and Controller to organize concerns and improve
maintainability.
42.Q: What is the Model in MVC? A: The component that manages data and
business logic.
43.Q: What is the View in MVC? A: The component responsible for displaying
data to the user.
44.Q: What is the Controller in MVC? A: The component that handles user
input and updates the model and view accordingly.
45.Q: What is the Dependency Injection pattern? A: A technique where an
object's dependencies are provided externally rather than created internally.
46.Q: What is a benefit of Dependency Injection? A: It improves testability and
reduces tight coupling between classes.
47.Q: What is the Null Object pattern? A: Uses a neutral "do nothing" object
instead of null references to avoid null checks.
48.Q: What is the difference between Strategy and State patterns? A: Strategy
lets a client choose an algorithm; State lets an object change behavior
automatically based on its internal state.
49.Q: What is the difference between Facade and Adapter? A: Facade
simplifies access to a complex subsystem; Adapter converts one interface
into another expected interface.
50.Q: Why are design patterns important in software development? A: They
provide tested, reusable solutions that improve code readability, flexibility,
and maintainability.

You might also like