Interview Practise Flashcards

1
Q

What is React, and what are its key features?

A

Explain declarative views, component-based architecture, Virtual DOM, and unidirectional data flow.

  • JavaScript library for UI
  • Virtual DOM: React uses a lightweight in-memory representation of the DOM to update only the necessary parts efficiently, improving performance.
  • Single Page Application (SPA) is a web app that loads a single HTML page and dynamically updates its content as the user interacts
  • Component-Based Architecture: Applications are built as reusable, independent components, promoting modularity and ease of maintenance.
    -Unidirectional Data Flow: Data flows in a single direction, from parent to child components, ensuring predictable updates and easier debugging.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is JSX, and why is it used?

A

Discuss how JSX combines HTML and JavaScript for component rendering and its necessity for React.createElement.

  1. It allows developers to write HTML-like code within JavaScript, combining markup and logic in one file.
  2. JSX is transpiled into regular JavaScript by tools like Babel, enabling browsers to interpret it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the Virtual DOM, and how does it improve performance?

A

Explain its role in reconciling changes with minimal real DOM updates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the differences between functional and class components?

A

Highlight the simplicity of functional components and the introduction of hooks vs. lifecycle methods in class components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does state differ from props in React?

A

Discuss immutability of props and the mutable nature of state, including their roles in component behavior.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is prop drilling, and how do you handle it?

A

Mention Context API or state management libraries (Redux, Zustand) to manage deeply nested props.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are React Hooks, and why were they introduced?

A

Focus on state and lifecycle management in functional components, mentioning useState, useEffect, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does the useEffect hook work, and what are its common use cases?

A

Explain dependency arrays, cleanup functions, and scenarios like data fetching or event listeners.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the Context API, and when would you use it?

A

Discuss global state management for prop drilling avoidance.

the Context API and useContext are related but not the same.
The Context API is the entire system provided by React to manage and share state or data globally across components without passing props through every level of the tree.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How does React handle component re-rendering, and how can you optimize it?

A

Mention memoization (React.memo, useMemo, useCallback) and key props for efficient updates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are Higher-Order Components (HOCs) and Render Props?

A

Explain how these patterns enhance component reusability and encapsulate logic.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are React portals, and why are they used?

A

Discuss rendering child components outside the DOM hierarchy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are some methods to improve the performance of a React application?

A

Talk about lazy loading, code splitting, React Profiler, memoization, and optimizing dependencies in useEffect.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the difference between controlled and uncontrolled components?

A

Explain form data handling via React state (controlled) vs. direct DOM manipulation (uncontrolled).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How would you test a React component?

A

Cover tools like Jest, React Testing Library, and the importance of unit, integration, and snapshot testing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are microservices, and how do they differ from monolithic architectures?

A

Microservices are an architectural style where an application is composed of small, independent services, each responsible for a specific business function. These services communicate via APIs (e.g., REST, gRPC) and are independently deployable, scalable, and maintainable.

Differences:

Monolithic: Single codebase, tightly coupled components; changes or scaling affect the entire system.
Microservices: Decentralized, loosely coupled services; easier to scale, update, and debug individual components.

17
Q

What does high availability mean in the context of system design?

A

High availability (HA) ensures a system remains operational and accessible with minimal downtime, often measured as a percentage (e.g., “99.99% uptime”).

Elastic Load Balancer (ELB):

Purpose: Distributes incoming traffic across multiple instances in one or more Availability Zones (AZs).
Role in HA: Ensures that traffic is directed only to healthy instances, automatically rerouting if an instance fails.
Types: Application Load Balancer (ALB), Network Load Balancer (NLB), and Gateway Load Balancer (GLB), each suited for different use cases.
Availability Zones (AZs):

Purpose: Data centers in distinct locations within a region, designed for fault isolation and interconnected with low-latency networks.
Role in HA: Deploying resources across multiple AZs ensures redundancy. If one AZ fails, the application remains accessible via resources in another AZ.
Auto Scaling:

Purpose: Automatically adjusts the number of instances in response to traffic changes.
Role in HA: Maintains sufficient capacity to handle spikes in traffic and replaces failed instances.

18
Q

What is fault tolerance, and how does it differ from high availability?

A

Fault tolerance is the ability of a system to continue functioning correctly even when some components fail. It focuses on resilience and recovery from partial failures.

Difference:

High Availability: Prevents downtime by minimizing failures or disruptions.
Fault Tolerance: Ensures the system operates despite failures, often with degraded functionality.
Both aim to enhance system reliability but approach it differently.

19
Q

AWS, HA and Fault tolerence

A

Frontend:

Use an Application Load Balancer to distribute traffic across EC2 instances deployed in multiple AZs.
Backend Services:

Place services in an Auto Scaling group spanning multiple AZs for redundancy.
Use Amazon RDS with Multi-AZ for database failover.
Storage:

Store static assets in Amazon S3, ensuring high durability and availability.
Global Availability:

Use Route 53 with health checks and routing policies to direct traffic to the closest or healthiest region.