Paytm Interview Questions
Practice with real Paytm interview questions
01
A Frontend Developer was asked
Asked in 2024
Q. What are components and props in React? Provide an example of a functional component using props.
Ans. In React, components are the building blocks of the user interface. They are reusable pieces of code that return JSX (JavaScript XML) to render on the screen. Props (short for properties) are a mechanism for passing data from one component to another, usually from a parent component to a child component.
Here's an example of a functional component that uses props:
In this example, the
Greeting component accepts a name prop, which it uses to display a personalized greeting. The App component renders two Greeting components with different names, demonstrating how props can be used to pass data to child components.Frontend DeveloperCore Concept
02
A Software Engineer was asked
Asked in 2024
Q. Compare and contrast REST and GraphQL API design. Provide examples of scenarios where one might be preferred over the other.
Ans. REST (Representational State Transfer) and GraphQL are two prevalent approaches to API design. Each has its strengths and is suitable for different scenarios.
REST:
1. Endpoint-based: REST APIs are structured around resources, each identified by a unique URL. Each resource has its own endpoint.
2. HTTP Methods: REST uses standard HTTP methods (GET, POST, PUT, DELETE) to perform operations on resources.
3. Data Over-fetching: Clients may receive more data than they need since each endpoint returns a fixed structure.
Example REST API Endpoint:
GraphQL:
1. Single Endpoint: GraphQL APIs operate through a single endpoint, allowing clients to send queries for exactly the data they need.
2. Flexible Queries: Clients can specify the shape of the response, which reduces over-fetching and under-fetching of data.
3. Versioning: GraphQL APIs can evolve without breaking existing queries, as clients request precisely what they require.
Example GraphQL Query:
When to Use:
- REST is preferred in scenarios where a simple and well-defined structure is needed, especially for CRUD operations with less complex relationships.
- GraphQL is better suited for applications with complex data requirements and relationships, where clients need flexibility in fetching data and minimizing the number of requests.
Conclusion:
Both REST and GraphQL have their own advantages and best use cases. The choice between them should be guided by the specific needs of the application and its clients.
Software EngineerCore Concept
