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

Interview Notes

The document contains interview notes covering core concepts and Q&A for Java, JavaScript, C++, SQL, Spring Boot, and Hibernate/JPA. It includes explanations of object-oriented programming principles, Java collections, exception handling, asynchronous programming in JavaScript, memory management in C++, SQL joins and indexing, and Spring Boot features like dependency injection. Each section provides a brief overview of key topics and differences between related concepts.

Uploaded by

ritvikrajput8299
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 views19 pages

Interview Notes

The document contains interview notes covering core concepts and Q&A for Java, JavaScript, C++, SQL, Spring Boot, and Hibernate/JPA. It includes explanations of object-oriented programming principles, Java collections, exception handling, asynchronous programming in JavaScript, memory management in C++, SQL joins and indexing, and Spring Boot features like dependency injection. Each section provides a brief overview of key topics and differences between related concepts.

Uploaded by

ritvikrajput8299
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

INTERVIEW NOTES

Java

Core Concepts

• OOP Concepts:

o Inheritance: A mechanism where a new class (subclass) derives properties and


behaviors from an existing class (superclass). It promotes code reuse.

o Polymorphism: The ability of an object to take on many forms. It allows


methods to be called on objects of different types that share a common
superclass or interface.

o Encapsulation: The bundling of data and methods that operate on that data into
a single unit (a class). It hides the internal state of an object from the outside
world.

o Abstraction: The process of hiding complex implementation details and


showing only the essential features of the object. It can be achieved using
abstract classes and interfaces.

• Collections Framework:

o List: An ordered collection (sequence). Elements can be accessed by their


index. Duplicates are allowed. Common implementations: ArrayList, LinkedList.

o Set: A collection that does not allow duplicate elements. It models the
mathematical concept of a set. Common implementations: HashSet, TreeSet.

o Map: An object that maps keys to values. A Map cannot contain duplicate keys;
each key can map to at most one value. Common implementations: HashMap,
TreeMap, Hashtable.

o Queue: A collection designed for holding elements prior to processing. It


typically orders elements in a FIFO (First-In, First-Out) manner. Common
implementations: PriorityQueue, LinkedList.

• Java 8+ Features:

o Streams: A sequence of elements from a source that supports aggregate


operations like filter, map, reduce. They allow for a functional approach to
processing data.

o Lambda Expressions: Provide a clear and concise way to represent a method


with a single abstract method (functional interface).

o Optional: A container object which may or may not contain a non-null value. It
helps in avoiding NullPointerExceptions.
o Functional Interfaces: An interface with exactly one abstract method. They are
a key component for using lambda expressions.

• Exception Handling:

o Checked Exceptions: Checked at compile time. They must be handled by either


a try-catch block or a throws clause in the method signature. Examples:
IOException, SQLException.

o Unchecked Exceptions: Not checked at compile time. They are runtime


exceptions and are not required to be handled. Examples: NullPointerException,
ArrayIndexOutOfBoundsException.

• Multithreading:

o synchronized: A keyword used to control access to a method or block of code by


multiple threads. It ensures that only one thread can execute a synchronized
block at a time.

o volatile: Ensures that changes to a variable are immediately visible to all


threads. It prevents threads from caching a variable's value.

o Executors: Framework for managing and executing threads. It separates thread


creation/management from the tasks to be executed. ExecutorService is a
common interface.

o Deadlock: A situation where two or more threads are blocked forever, waiting for
each other to release a lock.

o Race Condition: A situation where multiple threads try to access and modify
the same shared data, and the outcome depends on the unpredictable order of
execution.

• JVM Internals:

o Heap vs Stack:

▪ Stack Memory: Stores local variables, method call frames, and primitive
data types. Each thread has its own private stack. It is faster than heap
memory.

▪ Heap Memory: Used for storing objects and their instance variables. It is
shared among all threads. Garbage collection operates on the heap.

o Garbage Collection: An automatic process that reclaims memory occupied by


objects that are no longer being used or referenced by the program.

Q&A: Java

Q: Difference between HashMap and Hashtable?

• Synchronization: Hashtable is synchronized, meaning it's thread-safe. All its public


methods are synchronized, which makes it suitable for use in a multithreaded
environment. HashMap is not synchronized and is not thread-safe.
• Performance: Since HashMap is not synchronized, it generally provides better
performance than Hashtable in single-threaded environments. The overhead of
acquiring and releasing locks in Hashtable can slow it down.

• Nulls: HashMap allows one null key and multiple null values. Hashtable does not
allow any null keys or null values. If you try to insert one, it will throw a
NullPointerException.

• Inheritance: Hashtable is a legacy class and inherits from Dictionary, while HashMap is
part of the modern Java Collections Framework and inherits from AbstractMap.

Q: Explain final, finally, and finalize().

• final: A keyword used to restrict a variable, class, or method.

o final variable: The value cannot be changed after it's initialized. It's a constant.

o final method: Cannot be overridden by subclasses.

o final class: Cannot be subclassed (inherited).

• finally: A block of code used in exception handling. It always executes, whether an


exception is thrown or not, and is typically used for cleanup code like closing resources
(files, database connections).

• finalize(): A method of the Object class. It is called by the Garbage Collector just before
an object is destroyed and its memory is reclaimed. Its use is generally discouraged due
to unpredictable behavior and performance issues. It's better to use try-with-resources
or the finally block for resource management.

JavaScript

Core Concepts

• ES6 Features: let/const (block scope), arrow functions (concise syntax, no this binding),
template literals (string interpolation), spread/rest operators, destructuring (unpacking
values from arrays/objects).

• Event Loop: A key mechanism for handling asynchronous operations in JavaScript. It


manages the execution of code, collecting and processing events, and executing sub-
tasks.

• Callbacks, Promises, async/await: Different approaches to handling asynchronous


code.

o Callbacks: Functions passed as arguments to other functions, to be executed


later. Can lead to "callback hell."

o Promises: Objects that represent the eventual completion (or failure) of an


asynchronous operation and its resulting value. Promise chains help avoid
callback hell.

o async/await: Syntactic sugar built on top of Promises, making asynchronous


code look and behave like synchronous code, which improves readability.
• Closures: A function bundled together with references to its surrounding state (the
lexical environment). This allows a function to access variables from its outer scope
even after the outer function has finished executing.

• this keyword: Refers to the context in which a function is executed. Its value depends
on how the function is called.

• Hoisting: JavaScript's default behavior of moving declarations to the top of their


containing scope before code execution.

• Scope: The accessibility of variables, objects, and functions in different parts of your
code.

• Prototype chain: A mechanism for objects to inherit properties from a "prototype


object." All JavaScript objects have a __proto__ property that points to their prototype.

• == vs ===:

o == (loose equality): Checks for equality after type coercion. 1 == "1" is true.

o === (strict equality): Checks for equality without type coercion. Both the value
and the type must be the same. 1 === "1" is false.

Q&A: JavaScript

Q: What is the Event Loop in JS?

The Event Loop is a single-threaded loop that continuously checks the call stack and the
message queue.

• Call Stack: Where synchronous function calls are placed. When a function returns, it's
popped off the stack.

• Web APIs: Asynchronous operations like setTimeout, fetch, or DOM events are handled
by the browser's Web APIs.

• Message Queue (or Task Queue): Where the callbacks for asynchronous operations are
placed once the Web API has completed its task.

• The Loop: The Event Loop constantly checks if the call stack is empty. If it is, it takes
the first message from the message queue and pushes its corresponding callback onto
the call stack for execution. This non-blocking behavior is what allows JavaScript to
handle time-consuming operations without freezing the UI.

Q: Explain closure with example.

A closure is when a function remembers and can access its surrounding variables, even after
the outer function has finished executing.

Example:

JavaScript

function makeAdder(x) {
// 'x' is part of the closure

return function(y) {

return x + y;

};

const addFive = makeAdder(5);

[Link](addFive(2)); // Output: 7

[Link](addFive(10)); // Output: 15

In this example, makeAdder returns a new function. This new function "closes over" the variable
x from makeAdder's scope. Even though makeAdder has finished running, the addFive function
still has access to the value of x (which is 5). This is the closure in action.

C++

Core Concepts

• Memory Management:

o Stack: Memory allocated for local variables and function calls. It's managed
automatically and is very fast.

o Heap: Dynamic memory used for objects created with new. It must be managed
manually (with delete) or using smart pointers to avoid memory leaks.

• Pointers, References, Smart Pointers:

o Pointers: A variable that stores a memory address. It can be nullptr.

o References: An alias for an existing variable. It must be initialized at declaration


and cannot be changed to refer to another variable. It can't be nullptr.

o Smart Pointers: Objects that act like pointers but automatically manage
memory to prevent memory leaks. Examples: std::unique_ptr, std::shared_ptr.

• OOP:

o Virtual functions: A member function declared with the virtual keyword. It


enables runtime polymorphism, allowing a function call to be resolved at
runtime based on the object's type.

o Pure virtual function: A virtual function with a = 0; declaration. A class


containing one or more pure virtual functions is an abstract class.

o Abstract class: A class that cannot be instantiated on its own. It's designed to
be a base class for other classes, forcing them to implement the pure virtual
functions.
Q&A: C++

Q: Difference between deep copy & shallow copy.

• Shallow Copy: Creates a new object, but instead of creating new copies of the
members (especially pointers or complex objects), it copies the memory addresses
(pointers) of the members from the original object. This means both the original and the
new object point to the same underlying data. If one object's data is modified, it will
affect the other.

• Deep Copy: Creates a new object and allocates new memory for all the members,
recursively copying the data from the original object. The new object is a completely
independent copy, and changes to one object's data will not affect the other. A deep
copy is essential when an object contains pointers or dynamically allocated memory.

SQL

Core Concepts

• Joins: INNER, LEFT, RIGHT, FULL joins combine rows from two or more tables based on
a related column. SELF join is a regular join that joins a table to itself.

• Normalization: A process of organizing a database to reduce data redundancy and


improve data integrity. It follows a series of forms (1NF, 2NF, 3NF, BCNF).

• Indexes: Data structures that improve the speed of data retrieval operations on a
database table. They act like an index in a book.

• ACID Properties: Atomicity, Consistency, Isolation, Durability. These are a set of


properties that guarantee that database transactions are processed reliably.

• Common functions: COUNT (counts rows), GROUP BY (groups rows with the same
values), HAVING (filters groups created by GROUP BY), ROW_NUMBER() (assigns a
unique number to each row within a partition).

Q&A: SQL

Q: How does indexing improve performance?

Indexing improves performance by providing a fast way to look up data. Instead of scanning the
entire table (a "full table scan") to find a specific row, the database can use the index to quickly
jump to the data location.

• Faster reads: Queries with WHERE clauses, ORDER BY, and JOIN operations that use
indexed columns will execute much faster.

• Drawbacks: Indexes do add some overhead. They require additional storage space and
can slow down write operations (INSERT, UPDATE, DELETE), as the database needs to
update both the table data and the index itself.
Q: Difference between WHERE and HAVING.

• WHERE clause: Filters individual rows before they are grouped. It cannot use
aggregate functions like COUNT or SUM.

• HAVING clause: Filters groups of rows after they have been created by the GROUP BY
clause. It must be used with GROUP BY and can use aggregate functions.

Analogy:

• WHERE is like picking out specific ingredients from a shelf (e.g., "only get the red
apples").

• HAVING is like sorting those ingredients into different types and then filtering the groups
(e.g., "from all the fruit, only keep the groups that have more than 5 items").

Backend

Spring Boot

• Dependency Injection (DI): A design pattern where an object receives its dependencies
from an external source rather than creating them itself.

• IoC (Inversion of Control): A principle where the framework (Spring) manages the
objects' lifecycle and dependencies, rather than the application managing them. DI is a
form of IoC.

• Annotations:

o @RestController: Combines @Controller and @ResponseBody for building


RESTful APIs.

o @Service: A stereotype annotation for service layer components.

o @Repository: A stereotype annotation for data access layer components. It


provides a way to handle persistence exceptions.

o @Autowired: Marks a constructor, field, or setter method to be autowired by


Spring's DI.

• Auto-configuration: Spring Boot's ability to automatically configure a Spring application


based on the dependencies present in the classpath.

• JPA/Hibernate: Spring Data JPA simplifies the implementation of data access layers.
@Entity maps a class to a database table, @Id defines the primary key, @OneToMany,
@ManyToMany define relationships.

Q&A: Spring Boot

Q: How does Spring Boot reduce boilerplate code?

Spring Boot reduces boilerplate code through several key features:


• Auto-configuration: It automatically configures your application based on the libraries
you've included. For example, if you add the spring-boot-starter-web dependency, it
automatically configures a Tomcat server, a DispatcherServlet, etc.

• Starter dependencies: These are pre-packaged collections of dependencies that are


commonly used together. For example, spring-boot-starter-data-jpa brings in Hibernate,
Spring Data JPA, and a Hikari connection pool, all configured to work together.

• Opinionated defaults: Spring Boot provides sensible default configurations, so you


don't have to manually configure common things like logging, database connections,
etc. This allows you to focus on writing business logic.

Q: Difference between @Component, @Service, @Repository.

These are all stereotype annotations that mark a class as a Spring Bean, but they serve
different semantic purposes and enable specific features.

• @Component: A generic stereotype for any Spring-managed component. It's the base
annotation for the other two.

• @Service: A specialized @Component used for classes in the service layer. It's
primarily for semantic clarity, indicating that the class holds business logic.

• @Repository: A specialized @Component used for classes in the data access layer. It
has a special feature: it enables the translation of persistence-related exceptions into
Spring's DataAccessException hierarchy, making error handling more consistent.

Hibernate / JPA

• ORM (Object-Relational Mapping): A technique that allows you to work with a


database using objects in your programming language, rather than raw SQL. Hibernate is
a popular ORM tool.

• Lazy vs Eager Loading:

o Eager Loading: An associated object is loaded immediately along with the main
object. This can lead to performance issues if there are many associations.

o Lazy Loading: An associated object is only loaded when it is explicitly accessed.


This is the default for @OneToMany and @ManyToMany relationships in
Hibernate and is more efficient.

• HQL vs Native SQL:

o HQL (Hibernate Query Language): An object-oriented query language, similar


to SQL, but it operates on objects and their properties. It's database-
independent.

o Native SQL: The standard SQL used by the underlying database. It's database-
dependent and can be useful for complex, non-portable queries.

Q&A: Hibernate / JPA


Q: Difference between save() and persist().

Both methods are used to save an entity to the database, but they differ in their behavior and
state management.

• save(): A Hibernate-specific method. It returns the Serializable ID of the saved object. If


the object already exists in the database, it performs an UPDATE. If the object has no ID,
it performs an INSERT. It can save an object whether it's in a transaction or not.

• persist(): A JPA-specific method. It returns void. It saves a new entity to the database. If
the entity already exists, it will throw an exception. persist() requires a transaction
context and is the preferred method in modern JPA applications.

Key difference: persist() strictly follows the JPA specification and is used for new entities, while
save() is a more flexible (but less strict) Hibernate-specific method that can handle both new
and existing entities.

[Link] / Express

• Event-driven, non-blocking I/O: [Link] uses an event-driven architecture. It


processes I/O operations (like database queries, file reads) asynchronously, without
blocking the main thread. This makes it highly efficient for I/O-bound tasks.

• Middleware: Functions that have access to the request object (req), the response
object (res), and the next middleware function in the application's request-response
cycle. They can modify req and res or end the cycle.

• Routing: Defining how an application responds to client requests to specific endpoints.

• express: A minimal and flexible [Link] web application framework.

Q&A: [Link] / Express

Q: Difference between synchronous and asynchronous code in [Link].

• Synchronous: Code is executed in a blocking, step-by-step manner. Each operation


must finish before the next one can start. This can lead to a frozen application for time-
consuming tasks.

• Asynchronous: Code is executed in a non-blocking manner. An operation (e.g., a file


read) is started, but the program doesn't wait for it to finish. Instead, it continues to the
next line of code. When the operation is complete, a callback is executed. [Link]'s
asynchronous nature, powered by the Event Loop, is what makes it so fast and scalable.

RESTful APIs / Microservices

• RESTful APIs: A set of architectural principles for designing networked applications. It's
based on the use of HTTP methods to perform CRUD operations on resources.

• Principles:
o Statelessness: Each request from a client to the server must contain all the
information needed to understand the request.

o Resource-based URLs: Resources are identified by a URI (e.g., /api/users).

o JSON responses: Data is typically returned in JSON format.

• HTTP Methods: GET (retrieve), POST (create), PUT (update/replace), DELETE (delete),
PATCH (partial update).

• Status Codes: 200 (OK), 201 (Created), 400 (Bad Request), 401 (Unauthorized), 403
(Forbidden), 404 (Not Found), 500 (Internal Server Error).

• Microservices: An architectural style that structures an application as a collection of


small, independent services, each running in its own process and communicating via
APIs.

Q&A: RESTful APIs / Microservices

Q: How do you handle inter-service communication in microservices?

The two main ways to handle inter-service communication are:

1. Synchronous Communication (REST): One service calls another directly and waits for
a response. This is simple but can lead to tight coupling and cascading failures. A
common protocol is HTTP/REST.

2. Asynchronous Communication (Messaging): Services communicate indirectly


through a message broker (like Kafka or RabbitMQ). A service publishes a message to a
topic/queue, and other services consume it. This decouples services, improves
resilience, and is suitable for high-volume, event-driven architectures.

Q: Difference between Monolithic and Microservice architecture.

• Monolithic: A single, self-contained unit where all components of the application (UI,
business logic, data access) are tightly coupled and packaged together. It's simpler to
develop initially and deploy, but scaling, maintenance, and adopting new technologies
can be challenging.

• Microservice: An application is broken down into small, independent services. Each


service is self-contained, has its own database, and can be developed, deployed, and
scaled independently. This offers flexibility, resilience, and scalability but adds
complexity in terms of distributed systems management.

Frontend

React

• Components: The building blocks of a React application. Functional components are


simple JavaScript functions, while Class components are ES6 classes. Functional
components with hooks are now the standard.
• Hooks: Functions that let you "hook into" React state and lifecycle features from
functional components. useState (for state), useEffect (for side effects), useContext (for
context), etc.

• Props vs State:

o Props (Properties): Used to pass data from a parent component to a child


component. They are read-only and immutable.

o State: An object that holds data that may change over the lifetime of a
component. It's managed internally by the component.

• Virtual DOM & Reconciliation:

o Virtual DOM: A lightweight, in-memory representation of the real DOM.

o Reconciliation: The process by which React compares the new Virtual DOM
with the old one to identify the most efficient way to update the real DOM. This
"diffing" process makes React very fast.

Q&A: React

Q: What is the difference between useMemo and useCallback?

Both are hooks used for performance optimization through memoization.

• useMemo: Memoizes a value. It returns a memoized value, so it only recomputes it


when one of its dependencies changes. It's useful for preventing expensive calculations
on every render.

• useCallback: Memoizes a function. It returns a memoized callback, so the function


itself is not re-created on every render. This is crucial when passing callbacks to child
components that rely on reference equality to prevent unnecessary re-renders (e.g., with
[Link]).

In short: useMemo is for values, useCallback is for functions.

Q: How does reconciliation work in React?

Reconciliation is the algorithm React uses to update the UI efficiently.

1. When a component's state or props change, React creates a new Virtual DOM tree for
the updated component.

2. It then compares this new tree with the previous Virtual DOM tree (the "diffing"
process).

3. Based on this comparison, it identifies the minimal number of changes needed to


make the real DOM reflect the new state.

4. Finally, it performs the updates directly on the real DOM, but only for the parts that have
actually changed. This is much faster than manipulating the entire real DOM tree.
HTML & CSS

• Semantic HTML: Using HTML tags that convey meaning and structure to the content,
like <article>, <section>, <header>, <footer>, etc. This improves accessibility and SEO.

• CSS Flexbox & Grid: Layout modules for creating flexible and responsive layouts.

o Flexbox: A one-dimensional layout system (row or column).

o Grid: A two-dimensional layout system (rows and columns simultaneously).

• Media Queries: CSS rules that apply styles based on the device's characteristics (e.g.,
screen width, height, resolution). Essential for responsive design.

• Pseudo-classes (:hover, :first-child) & Pseudo-elements (::before, ::after): Selectors


used to style specific states or parts of an element.

• Accessibility (A11y): Making websites usable by people with disabilities. alt text for
images and ARIA roles are crucial for screen readers.

Q&A: HTML & CSS

Q: Difference between relative, absolute, fixed, sticky positioning.

• position: static;: The default position. The element follows the normal flow of the page.
Top, bottom, left, right properties have no effect.

• position: relative;: The element is positioned relative to its normal position. Using top,
bottom, left, right will move it from that original position, but its original space remains
in the document flow.

• position: absolute;: The element is removed from the normal document flow and
positioned relative to its closest positioned ancestor. If no positioned ancestor exists,
it's relative to the <html> element.

• position: fixed;: The element is removed from the normal document flow and
positioned relative to the viewport. It remains in the same position even when the page
is scrolled. Useful for fixed headers or footers.

• position: sticky;: A hybrid of relative and fixed. The element behaves like relative until a
certain scroll position is reached, at which point it "sticks" and behaves like fixed.

Tailwind CSS

• Utility-first CSS framework: Instead of pre-built components, it provides low-level


utility classes (flex, p-4, shadow-md) that you can combine directly in your HTML to
build custom designs.

Q&A: Tailwind CSS

Q: How is Tailwind different from traditional CSS?


• Methodology: Traditional CSS involves writing custom CSS rules in a separate file for
each component or page. You often end up with a lot of custom classes that are only
used once. Tailwind promotes a utility-first approach where you compose UI directly in
your HTML using pre-defined, single-purpose classes.

• Boilerplate: Tailwind reduces the need to name classes and manage large CSS files.

• Customization: Tailwind is highly configurable, allowing you to define your own color
palettes, spacing scales, etc.

• Maintenance: Changes are localized to the HTML, making it easier to maintain and
refactor components without worrying about side effects.

Radix UI

• Headless UI library: Provides unstyled, accessible, and high-quality UI components


(like dropdowns, modals, etc.) that you can build upon. It handles the logic,
accessibility, and state, but leaves the styling completely to you.

Q&A: Radix UI

Q: Why use Radix UI instead of just CSS/HTML?

While you could build every UI component from scratch with just CSS and HTML, it would be
extremely time-consuming to ensure they are fully accessible (keyboard navigation, ARIA
attributes), maintain a consistent state (open/closed, disabled), and handle all the necessary
interactions.

• Accessibility: Radix provides a strong foundation for accessible components, handling


complex ARIA attributes and keyboard interactions out-of-the-box.

• Logic and State: It manages the state and logic for complex components, freeing you
from writing that boilerplate code yourself.

• Styling Freedom: It's headless, meaning it doesn't impose any styling. You can use any
CSS method, including Tailwind CSS, to style the components exactly how you want.
This is a key advantage over pre-styled UI libraries like Bootstrap or Material UI.

Databases

• MySQL: A popular relational database management system (RDBMS) that stores data
in tables. It enforces a strict schema, supports transactions, and is widely used.

• MongoDB: A NoSQL database that stores data in flexible, JSON-like documents. It's
schema-less, making it suitable for applications with rapidly changing data
requirements.

• PostgreSQL: An advanced RDBMS known for its robust features, extensibility, and
compliance with SQL standards. It also offers advanced data types and JSONB support.
Q&A: Databases

Q: When would you choose MongoDB over MySQL?

Choose MongoDB (NoSQL) when:

• You need a flexible, dynamic schema. The data model can change over time without
requiring a rigid database migration. This is great for agile development.

• You need to handle a high volume of writes and reads.

• The data is hierarchical or document-oriented, where you can embed related data
within a single document (e.g., a blog post and its comments). This reduces the need for
complex joins.

Choose MySQL (Relational) when:

• Data integrity and consistency are paramount. It is designed for applications that
require ACID properties.

• The data has a well-defined, rigid structure and relationships.

• You need to perform complex transactions involving multiple tables.

Cloud & Tools

AWS (Basics)

• EC2 (Elastic Compute Cloud): Provides resizable compute capacity in the cloud. It's
essentially a virtual server.

• S3 (Simple Storage Service): Object storage service that can be used to store and
retrieve any amount of data from anywhere on the web.

• RDS (Relational Database Service): Managed service for relational databases (MySQL,
PostgreSQL, etc.). It automates tasks like patching and backups.

• Lambda: A serverless compute service that runs your code in response to events and
automatically manages the underlying compute resources.

Q&A: AWS

Q: Difference between EC2 and Lambda.

Feature EC2 (Elastic Compute Cloud) Lambda

Function-as-a-Service (FaaS)
Model Infrastructure-as-a-Service (IaaS)
/ Serverless
Feature EC2 (Elastic Compute Cloud) Lambda

Full control over the server (OS, runtime, No control over the underlying
Control
etc.). infrastructure.

Charged per millisecond of


Charged by the hour (or second) while the
Billing execution and number of
instance is running.
requests.

You manage scaling (e.g., using Auto Scales automatically in


Scaling
Scaling groups). response to triggers.

Long-running applications, custom server


Ideal Event-driven, intermittent
configurations, workloads with
For tasks, APIs, data processing.
predictable traffic.

Docker

• Containerization: A lightweight virtualization method that packages an application and


its dependencies into a single, isolated unit called a container.

• Image: A read-only template with instructions for creating a Docker container.

• Container: A runnable instance of a Docker image.

Q&A: Docker

Q: Difference between Docker and VM.

Feature Docker (Containerization) VM (Virtualization)

Resource Lightweight, runs directly on the Heavyweight, runs a full guest


Usage host OS kernel. OS.

Startup Time Milliseconds (very fast). Minutes (slower).

Highly portable, runs the same on Less portable due to the full
Portability
any OS with Docker. OS.
Feature Docker (Containerization) VM (Virtualization)

A container shares the host OS A VM has its own guest OS,


Architecture
kernel. running on a hypervisor.

Kubernetes

• Orchestration: Automates the deployment, scaling, and management of containerized


applications.

• Pods: The smallest deployable unit in Kubernetes. A Pod contains one or more
containers.

• Deployments: Manages a set of identical Pods and ensures they are running.

• Services: An abstraction that defines a logical set of Pods and a policy by which to
access them.

Q&A: Kubernetes

Q: Difference between Deployment and StatefulSet.

• Deployment: Designed for stateless applications. It manages a set of identical Pods,


and if a Pod fails, it is replaced with a new one that is functionally identical but has a
new unique name.

• StatefulSet: Designed for stateful applications. It ensures that a fixed set of Pods is
running and provides a stable identity for each Pod (stable hostname, network ID, and
storage). This is crucial for databases, message queues, and other applications that
require persistent storage and ordered deployment/scaling.

Kafka

• Distributed messaging system: A platform for building real-time data pipelines and
streaming applications.

• Producer: Publishes messages to a Kafka topic.

• Consumer: Subscribes to and reads messages from a Kafka topic.

• Broker: A Kafka server.

• Topic: A category or feed name to which messages are published.

• Partition: Topics are divided into partitions, which are the fundamental unit of
parallelism.
Q&A: Kafka

Q: Difference between Kafka and RabbitMQ.

• Messaging Model:

o Kafka: A publish/subscribe model based on a distributed log. Messages are


persisted and can be replayed by consumers. It's designed for high-throughput,
stream-oriented data.

o RabbitMQ: An asynchronous messaging queue. Messages are consumed and


removed from the queue. It's designed for reliable, traditional message delivery.

• Use Cases:

o Kafka: Best for data streaming, real-time analytics, and event sourcing. It's a
high-throughput, durable log.

o RabbitMQ: Best for task queues, background job processing, and


microservice communication where guaranteed message delivery and explicit
acknowledgment are important.

Git

• git clone: Creates a copy of a remote repository on your local machine.

• git pull: Fetches changes from a remote repository and merges them into your current
branch.

• git push: Uploads local branch commits to the remote repository.

• git stash: Temporarily shelves changes you don't want to commit yet.

• git revert: Creates a new commit that undoes a previous commit.

Q&A: Git

Q: Difference between merge and rebase.

• git merge: Combines the changes from two branches by creating a new merge commit.
This preserves the history of both branches and is generally safer and non-destructive.

• git rebase: Moves or combines a sequence of commits to a new base commit. It


effectively "rewrites" history by creating new commits for the moved ones. This results in
a cleaner, linear history but can be dangerous if you're rebasing a branch that others are
working on.

Other Skills

ELK Stack / Splunk


• ELK Stack: An acronym for Elasticsearch (search and analytics), Logstash (data
processing), and Kibana (visualization). It's a popular open-source solution for
centralized logging.

• Splunk: A proprietary software for searching, monitoring, and analyzing machine-


generated big data.

Q&A: ELK Stack / Splunk

Q: How do you monitor microservices logs?

Monitoring microservice logs is critical due to their distributed nature. The best approach is
centralized logging, using a solution like the ELK Stack.

1. Collection: A logging agent (e.g., Filebeat) is deployed on each microservice instance to


collect logs from various sources (files, standard output).

2. Processing: Logstash processes these logs, parsing, enriching, and transforming them.

3. Storage/Indexing: Elasticsearch indexes the processed logs, making them searchable


and analyzable.

4. Analysis/Visualization: Kibana provides a dashboard for searching, visualizing, and


monitoring the logs, allowing developers to quickly debug issues across multiple
services.

Agile / Scrum

• Agile: A philosophy for software development that promotes iterative development,


collaboration, and adaptability.

• Scrum: A framework for implementing Agile development.

o Roles: Product Owner (defines product backlog), Scrum Master (facilitates the
process), Development Team (builds the product).

o Events: Sprint (a time-boxed iteration), Daily Standup (short daily meeting),


Sprint Retrospective (review and improve the process).

Q&A: Agile / Scrum

Q: Difference between Agile and Waterfall model.

• Agile: An iterative and incremental approach. The project is broken into small cycles
(sprints), and a working product is delivered at the end of each. It's flexible, and
requirements can change throughout the process.

• Waterfall: A sequential approach. Development flows downwards through distinct


phases (requirements, design, implementation, testing, deployment). Each phase must
be completed before the next one begins. It's rigid and works best when requirements
are well-understood and unlikely to change.
Responsive Web Design

• Responsive Web Design: An approach to web design that makes web pages render well
on a variety of devices and screen sizes.

Q&A: Responsive Web Design

Q: How do you make a website responsive?

1. Use a Mobile-first approach: Design for the smallest screen first and progressively
enhance the design for larger screens.

2. CSS Media Queries: Use @media rules to apply specific styles based on screen width,
allowing you to change layouts, font sizes, etc., for different devices.

3. Flexible Layouts: Use relative units like %, em, rem, vw/vh (viewport width/height)
instead of fixed units like px. Use CSS Flexbox and Grid for building flexible layouts that
adapt to screen size.

4. Flexible Images: Set images to max-width: 100%; to ensure they scale down within their
containers.

5. Viewport Meta Tag: Include <meta name="viewport" content="width=device-width,


initial-scale=1.0"> in the HTML <head> to tell the browser to render the page at the
device's screen width.

You might also like