0% found this document useful (0 votes)
37 views

Java Imp

Uploaded by

joyful hunter
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Java Imp

Uploaded by

joyful hunter
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 31

Certainly!

Here are detailed answers to the questions provided:

### Java Core Questions

1. **What is the difference between JDK, JRE, and JVM?**

- **JDK (Java Development Kit)**: A software development kit used to develop


Java applications.
It includes the JRE, an interpreter/loader (Java), a compiler (javac), an
archiver (jar), a documentation generator (Javadoc), and other tools needed for
Java development.
- **JRE (Java Runtime Environment)**: Provides the libraries, Java Virtual
Machine (JVM), and other components to run applications written in Java.
The JRE does not contain development tools such as compilers or debuggers.
- **JVM (Java Virtual Machine)**: An abstract machine that enables your computer
to run a Java program.
It is a specification that provides a runtime environment in which Java
bytecode can be executed.

2. **Explain the concept of Object-Oriented Programming (OOP) and its principles.**

- **OOP** is a programming paradigm based on the concept of "objects", which can


contain data and code. The four main principles of OOP are:
- **Encapsulation**: Bundling the data (variables) and methods (functions)
that operate on the data into a single unit or class,
and restricting access to some of the object's components.
- **Inheritance**: A mechanism where a new class inherits the properties and
behavior (methods) of another class. This promotes code reuse.
- **Polymorphism**: The ability to present the same interface for different
underlying forms (data types). A method can perform different functions based on
the object
that it is acting upon.
- **Abstraction**: The concept of hiding the complex implementation details
and showing only the essential features of the object.

3. **What are the key differences between `HashMap` and `Hashtable`?**

- **Synchronization**: `HashMap` is not synchronized, which means it is not


thread-safe. `Hashtable` is synchronized and thread-safe.
- **Null Values**: `HashMap` allows one null key and multiple null values.
`Hashtable` does not allow any null key or value.
- **Performance**: Due to the lack of synchronization, `HashMap` generally
performs better than `Hashtable`.

4. **What are exceptions in Java? How do you handle them?**

- **Exceptions** are events that disrupt the normal flow of a program's


instructions. They are objects that represent runtime errors or abnormal
conditions.
- **Handling exceptions**:
- **Try-Catch Block**: Wrap the code that might throw an exception in a `try`
block, and catch the exception in the `catch` block.
- **Finally Block**: A block that is always executed after the try-catch
block, used for cleanup code.
- **Throw**: Used to explicitly throw an exception.
- **Throws**: Used in method signatures to declare the exceptions that the
method can throw.

5. **Explain the concept of Java Streams and give an example of their usage.**
- **Java Streams**: A sequence of elements supporting sequential and parallel
aggregate operations. Streams are not data structures; they don’t store elements.
They are used to perform operations on collections
in a functional style.
- **Example**:
```java
List<String> names = Arrays.asList("John", "Jane", "Jack", "Doe");
List<String> filteredNames = names.stream()
.filter(name -> name.startsWith("J"))
.collect(Collectors.toList());
System.out.println(filteredNames); // Output: [John, Jane, Jack]
```

6. **What is the purpose of the `transient` keyword in Java?**

- The `transient` keyword is used to indicate that a field should not be


serialized. When an object is serialized, the transient fields are ignored and not
part of the serialized state.

7. **How does garbage collection work in Java?**

- **Garbage Collection**: An automatic memory management process that reclaims


memory occupied by objects that are no longer in use by the program.
The JVM periodically runs the garbage
collector to free up memory.
- **Mechanisms**:
- **Mark and Sweep**: Identifies which objects are no longer reachable and
then sweeps them up.
- **Generational Garbage Collection**: Divides objects into generations and
collects them differently based on their age.

### Spring Framework Questions

1. **What is Spring Framework and what are its main modules?**

- **Spring Framework**: A comprehensive framework for enterprise Java


development. It provides infrastructure support for developing Java applications.
- **Main Modules**:
- **Core Container**: Core, Beans, Context, SpEL.
- **Data Access/Integration**: JDBC, ORM, OXM, JMS, Transaction.
- **Web**: Web, Web-Servlet, Web-Struts, Web-Portlet.
- **AOP**: Aspect-Oriented Programming.
- **Instrumentation**: Instrumentation and classloader implementations.
- **Messaging**: Messaging module for message-oriented applications.
- **Test**: Support for testing with JUnit or TestNG.

2. **Explain the concept of Dependency Injection (DI) in Spring.**

- **Dependency Injection**: A design pattern used to implement IoC (Inversion of


Control), allowing the Spring container to manage the dependencies of beans.
Instead of the objects creating their
own dependencies, they are provided to them by the container.

3. **What is Spring Boot and how is it different from the traditional Spring
Framework?**

- **Spring Boot**: An extension of the Spring Framework that simplifies the


setup, development, and deployment of Spring applications by offering default
configurations and opinions over convention.
- **Differences**:
- **Auto-Configuration**: Automatically configures the Spring application
based on the jar dependencies.
- **Standalone**: Can run independently with an embedded server like Tomcat or
Jetty.
- **Convention over Configuration**: Sensible defaults for faster setup.

4. **How do you configure a Spring Boot application?**

- Spring Boot applications can be configured using properties files


(`application.properties` or `application.yml`), environment variables, and
command-line arguments.
Spring Boot also supports externalized configuration for different
environments.

5. **What are Spring Boot starters and how do they help in development?**

- **Spring Boot Starters**: POM dependencies that include a curated set of


dependencies for a specific purpose (e.g., `spring-boot-starter-web` for web
applications).
They simplify dependency management by
providing a consistent set of dependencies.

### Hibernate Questions

1. **What is Hibernate and what is it used for?**

- **Hibernate**: An ORM (Object-Relational Mapping) tool for Java. It simplifies


database interactions by mapping Java objects to database tables and vice versa,
providing an abstraction over the underlying
database.

2. **Explain the difference between `Session` and `SessionFactory` in Hibernate.**

- **SessionFactory**: A thread-safe, heavyweight object that creates and manages


`Session` instances. Typically, a single `SessionFactory` is created per
application.
- **Session**: A lightweight, non-thread-safe object used for performing CRUD
operations and managing transactions with the database.

3. **What are the advantages of using Hibernate over JDBC?**

- **Advantages**:
- **Simplified Data Access**: Reduces boilerplate code for database
interactions.
- **Automatic Table Creation**: Can automatically create and manage database
tables.
- **HQL (Hibernate Query Language)**: An object-oriented query language
similar to SQL.
- **Caching**: Supports first-level and second-level caching for better
performance.
- **Transaction Management**: Manages transactions and concurrency.

4. **Explain the concept of lazy loading in Hibernate.**

- **Lazy Loading**: A technique where the related entities are not loaded
immediately when the parent entity is loaded. They are loaded on-demand, which
improves performance by loading data only when necessary.
### Frontend Questions

1. **What is the difference between HTML and HTML5?**

- **HTML5**: The latest version of HTML. It includes new features such as


semantic elements (`<header>`, `<footer>`, `<article>`), new input types (`date`,
`email`, `url`), audio and
video elements, and improved support for CSS3 and
JavaScript APIs.

2. **Explain the CSS box model.**

- **CSS Box Model**: A box that wraps around HTML elements, consisting of:
- **Content**: The actual content of the box, where text and images appear.
- **Padding**: Clears an area around the content. It is transparent.
- **Border**: A border surrounding the padding (if any) and content.
- **Margin**: Clears an area outside the border. It is also transparent.

3. **What are the different ways to include CSS in a web page?**

- **Inline CSS**: Using the `style` attribute within HTML elements.


```html
<p style="color:blue;">This is a paragraph.</p>
```
- **Internal CSS**: Using a `<style>` tag within the `<head>` section of the
HTML document.
```html
<head>
<style>
p { color: blue; }
</style>
</head>
```
- **External CSS**: Linking to an external CSS file using the `<link>` tag.
```html
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
```

4. **Explain the concept of responsive web design.**

**Responsive Web Design**: An approach to web design that makes web pages render
well on a variety of devices and window or screen sizes. It uses flexible layouts,
flexible images, and CSS media queries.

5. **What is JavaScript and how is it different from Java?**

- **JavaScript**: A lightweight, interpreted programming language used primarily


for adding interactivity to web pages. It is a client-side scripting language.
- **Differences**:
- **Purpose**: Java is a programming language used for server-side
development, while JavaScript is used for client-side scripting.
- **Execution**: Java is compiled to bytecode and runs on the JVM, while
JavaScript is interpreted and runs in the browser.
6. **What are JavaScript promises and how do they work?**

- **Promises**: Objects representing the eventual completion or failure of an


asynchronous operation. They allow chaining of operations.
- **States**:
- **Pending**: Initial state, neither fulfilled nor rejected.
- **Fulfilled**: Operation completed successfully.
- **Rejected**: Operation failed.
- **Example**:
```javascript
let promise = new Promise((resolve, reject) => {
let success = true;
if (success) {
resolve("Success!");
} else {
reject("Failure!");
}
});

promise.then(result => {
console.log(result); // Success!
}).catch(error => {
console.log(error); // Failure!
});
```

7. **Explain the concept of a Single Page Application (SPA).**

- **Single Page Application (SPA)**: A web application that interacts with the
user by dynamically rewriting the current page rather than loading entire new pages
from the server.
This provides a more
fluid user experience similar to a desktop application.

### Angular/React/Vue.js

1. **What is Angular/React/Vue.js and why is it used?**

- **Angular**: A platform and framework for building single-page client


applications using HTML and TypeScript. It is maintained by Google.
- **React**: A JavaScript library for building user interfaces, particularly
single-page applications. It is maintained by Facebook.
- **Vue.js**: A progressive JavaScript framework used to build user interfaces
and single-page applications.

2. **Explain the concept of components in Angular/React/Vue.js.**

- **Components**: Reusable, self-contained pieces of UI that can be nested,


managed, and handled independently. Each component has its own logic and template.

3. **How does data binding work in Angular/React/Vue.js?**

- **Angular**: Uses two-way data binding by default, which synchronizes the


model and the view.
- **React**: Uses one-way data binding, where the state flows down from parent
to child components, and events flow up.
- **Vue.js**: Supports both one-way and two-way data binding.

4. **What is the purpose of a state management library (e.g., Redux, Vuex) in


frontend development?**

- **State Management Libraries**: Help manage the state of the application in a


predictable way. They allow for centralized state management, making it easier to
debug and maintain the application.

### Database Questions

1. **What is the difference between SQL and NoSQL databases?**

- **SQL Databases**: Relational databases that use structured query language


(SQL) for defining and manipulating data. They are table-based.
- **NoSQL Databases**: Non-relational databases designed for large-scale data
storage and for massively-parallel, high-performance data processing.
They can be document-based, key-value pairs,
wide-column stores, or graph databases.

2. **Explain the concept of normalization in databases.**

- **Normalization**: The process of organizing data in a database to reduce


redundancy and improve data integrity. It involves dividing large tables into
smaller tables and defining relationships between them.

3. **What is a join in SQL and what are the different types of joins?**

- **Join**: An SQL operation used to combine data from two or more tables based
on a related column.
- **Types of Joins**:
- **Inner Join**: Returns records with matching values in both tables.
- **Left Join (Left Outer Join)**: Returns all records from the left table and
the matched records from the right table.
- **Right Join (Right Outer Join)**: Returns all records from the right table
and the matched records from the left table.
- **Full Join (Full Outer Join)**: Returns all records when there is a match
in either left or right table.
- **Cross Join**: Returns the Cartesian product of both tables.

4. **How do you optimize a SQL query?**

- **Optimizing SQL Queries**:


- Use indexes to speed up searches.
- Avoid using `SELECT *` and specify only the columns needed.
- Use joins instead of subqueries.
- Limit the number of rows returned with `LIMIT` or `TOP`.
- Avoid unnecessary columns in `GROUP BY` and `ORDER BY` clauses.

5. **What is an ORM (Object-Relational Mapping) and how does it work?**

- **ORM**: A programming technique for converting data between incompatible


systems (object-oriented programming languages and relational databases).
It allows developers to interact with the database using
objects rather than SQL.

### General Software Engineering Questions

1. **Explain the concept of RESTful APIs and how they are used.**

- **RESTful APIs**: Web services that adhere to the REST (Representational State
Transfer) architecture.
They use HTTP methods (GET, POST, PUT, DELETE) to
perform CRUD operations on resources, which are typically represented by URLs.

2. **What is version control and why is it important?**

- **Version Control**: A system that records changes to files over time so that
you can recall specific versions later.
It is important for collaboration, tracking
changes, and maintaining a history of the project's development.

3. **What are microservices and what are their advantages?**

- **Microservices**: An architectural style that structures an application as a


collection of loosely coupled services, each implementing a specific business
capability.
- **Advantages**:
- Improved scalability and flexibility.
- Independent development and deployment.
- Enhanced fault isolation.
- Technology diversity.

4. **How do you ensure the security of a web application?**

- **Ensuring Security**:
- Use HTTPS to encrypt data in transit.
- Implement input validation to prevent injection attacks.
- Use authentication and authorization to restrict access.
- Store sensitive data securely using hashing and encryption.
- Regularly update and patch software dependencies.
- Conduct security testing and code reviews.

5. **Describe the software development lifecycle (SDLC).**

- **SDLC**: A process for planning, creating, testing, and deploying information


systems. Phases include:
- **Planning**: Define project goals and scope.
- **Analysis**: Gather and analyze requirements.
- **Design**: Create system architecture and design.
- **Implementation**: Write and compile code.
- **Testing**: Test the system for defects and issues.
- **Deployment**: Deploy the system to production.
- **Maintenance**: Monitor and update the system as needed.

### Behavioral Questions

1. **Can you describe a challenging project you worked on and how you overcame the
challenges?**

- **Answer**: [Your answer will be unique to your experience. Describe a


specific project, the challenges you faced, the steps you took to overcome them,
and the outcome.]

2. **How do you keep up with new technologies and advancements in your field?**

- **Answer**: "I regularly read tech blogs, follow industry leaders on social
media, participate in online courses and webinars, attend conferences, and
contribute to open-source projects."

3. **Describe a situation where you had to work with a difficult team member. How
did you handle it?**

- **Answer**: [Your answer will be unique to your experience. Describe the


situation, the difficulties, how you approached resolving the issues, and the
result.]

4. **How do you prioritize tasks when working on multiple projects?**

- **Answer**: "I prioritize tasks based on their deadlines, importance, and


impact. I use tools like project management software to keep track of tasks and
deadlines,
and I communicate with stakeholders to ensure alignment
on priorities."

5. **Can you provide an example of a time when you improved an existing system or
process?**

- **Answer**: [Your answer will be unique to your experience. Describe the


system or process, what improvements you made, the steps you took, and the results
achieved.]

### Coding Challenges

1. **Write a Java program to reverse a string without using any built-in


functions.**

```java
public class StringReversal {
public static void main(String[] args) {
String original = "Hello, World!";
String reversed = reverseString(original);
System.out.println("Reversed string: " + reversed);
}

public static String reverseString(String input) {


char[] characters = input.toCharArray();
StringBuilder reversed = new StringBuilder();
for (int i = characters.length - 1; i >= 0; i--) {
reversed.append(characters[i]);
}
return reversed.toString();
}
}
```

2. **Implement a function to check if a given number is a palindrome.**

```java
public class PalindromeCheck {
public static void main(String[] args) {
int number = 121;
boolean isPalindrome = isPalindrome(number);
System.out.println("Is the number a

palindrome? " + isPalindrome);


}

public static boolean isPalindrome(int number) {


int original = number;
int reversed = 0;
while (number != 0) {
int digit = number % 10;
reversed = reversed * 10 + digit;
number /= 10;
}
return original == reversed;
}
}
```

3. **Write a SQL query to find the second highest salary from the `employees`
table.**

```sql
SELECT MAX(salary) AS second_highest_salary
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
```

4. **Create a RESTful API using Spring Boot that performs CRUD operations on a
`Product` entity.**

```java
// Product.java
@Entity
public class Product {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private double price;

// Getters and setters


}

// ProductRepository.java
@Repository
public interface ProductRepository extends JpaRepository<Product, Long> {
}

// ProductController.java
@RestController
@RequestMapping("/api/products")
public class ProductController {
@Autowired
private ProductRepository productRepository;

@GetMapping
public List<Product> getAllProducts() {
return productRepository.findAll();
}

@GetMapping("/{id}")
public ResponseEntity<Product> getProductById(@PathVariable Long id) {
return productRepository.findById(id)
.map(product -> ResponseEntity.ok().body(product))
.orElse(ResponseEntity.notFound().build());
}
@PostMapping
public Product createProduct(@RequestBody Product product) {
return productRepository.save(product);
}

@PutMapping("/{id}")
public ResponseEntity<Product> updateProduct(@PathVariable Long id,
@RequestBody Product productDetails) {
return productRepository.findById(id)
.map(product -> {
product.setName(productDetails.getName());
product.setPrice(productDetails.getPrice());
Product updatedProduct = productRepository.save(product);
return ResponseEntity.ok().body(updatedProduct);
})
.orElse(ResponseEntity.notFound().build());
}

@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteProduct(@PathVariable Long id) {
return productRepository.findById(id)
.map(product -> {
productRepository.delete(product);
return ResponseEntity.ok().build();
})
.orElse(ResponseEntity.notFound().build());
}
}
```

These answers should help you prepare for a Java Fullstack Developer interview at
Kiya.ai or a similar organization.
Make sure to understand each concept thoroughly and be ready to provide examples or
write code during the interview.

Certainly! Here are more advanced Java Fullstack Developer interview questions
along with detailed answers:

### Advanced Java Questions

1. **Explain the concept of Java Memory Model (JMM) and its significance.**

- **Java Memory Model (JMM)**: Defines how threads interact through memory and
what behaviors are allowed in concurrent execution.
It addresses issues such as
visibility, ordering of reads and writes, and atomicity.
Key concepts include:
- **Visibility**: Ensures that changes made by one thread to shared variables
are visible to other threads.
- **Ordering**: Controls the order in which operations are executed and
perceived across different threads.
- **Atomicity**: Guarantees that a series of operations are completed without
interruption.

2. **What are the different types of class loaders in Java?**


- **Bootstrap Class Loader**: Loads core Java classes from the `<JAVA_HOME>/lib`
directory.
- **Extension Class Loader**: Loads classes from the `<JAVA_HOME>/lib/ext`
directory.
- **System/Application Class Loader**: Loads classes from the classpath
specified by the `-classpath` or `-cp` parameter.
- **Custom Class Loaders**: User-defined class loaders extending `ClassLoader`
to load classes in a specific way.

3. **Describe the Executor framework in Java and its advantages.**

- **Executor Framework**: A framework provided by Java to manage a pool of


worker threads efficiently.
It simplifies concurrent programming by
decoupling task submission from the execution of the tasks.
- **Advantages**:
- **Thread Pool Management**: Reuses a fixed number of threads to execute
tasks, improving performance.
- **Task Scheduling**: Schedules tasks for execution at specified intervals or
delays.
- **Simplified Concurrency**: Provides a higher-level API for managing
concurrency compared to manually creating and managing threads.

4. **What is a `volatile` keyword in Java and when would you use it?**

- The `volatile` keyword in Java ensures that the value of a variable is always
read from and written to the main memory, providing visibility guarantees across
threads.
- Use `volatile` when you need to ensure that updates to a variable are
immediately visible to other threads and atomicity is not a concern.

5. **Explain the concept of Java Reflection and its use cases.**

- **Java Reflection**: A feature that allows a program to examine and modify the
behavior of classes, methods, and fields at runtime. Use cases include:
- **Frameworks**: Building dependency injection frameworks.
- **Testing**: Writing generic testing frameworks.
- **Serialization**: Implementing custom serialization mechanisms.
- **Dynamic Proxies**: Creating dynamic proxy classes for AOP.

### Advanced Spring Framework Questions

1. **What is Spring AOP and how does it work?**

- **Spring AOP (Aspect-Oriented Programming)**: A programming paradigm that aims


to increase modularity by allowing the separation of cross-cutting concerns (e.g.,
logging, security).
It works
by weaving aspects into target objects at runtime or compile time.
- **Core Concepts**:
- **Aspect**: A module with cross-cutting concerns.
- **Join Point**: A point in the program execution (e.g., method execution).
- **Advice**: Action taken by an aspect at a join point (before, after,
around).
- **Pointcut**: Expressions that match join points.
- **Weaving**: The process of applying aspects to target objects.

2. **What is the difference between `@Component`, `@Service`, `@Repository`, and


`@Controller` in Spring?**
- **@Component**: A generic stereotype for any Spring-managed component.
- **@Service**: Indicates that a class holds business logic. It’s a
specialization of `@Component`.
- **@Repository**: Indicates that a class is a data repository (DAO). It’s a
specialization of `@Component` and provides persistence exception translation.
- **@Controller**: Indicates that a class serves as a web controller. It’s a
specialization of `@Component` used in MVC applications.

3. **Explain the concept of Spring Transactions and propagation levels.**

- **Spring Transactions**: Mechanisms provided by Spring to manage transactions


declaratively using annotations or programmatically using APIs.
- **Propagation Levels**:
- **REQUIRED**: Joins an existing transaction or creates a new one if none
exists.
- **REQUIRES_NEW**: Suspends the current transaction and creates a new one.
- **MANDATORY**: Supports a current transaction, throws an exception if none
exists.
- **SUPPORTS**: Supports a current transaction, executes non-transactionally
if none exists.
- **NOT_SUPPORTED**: Executes non-transactionally, suspends the current
transaction if exists.
- **NEVER**: Executes non-transactionally, throws an exception if a
transaction exists.
- **NESTED**: Executes within a nested transaction if a current transaction
exists.

4. **What is the difference between `@Transactional` and programmatic transaction


management in Spring?**

- **@Transactional**: Declarative transaction management using annotations.


It simplifies transaction management by
defining transaction boundaries declaratively in the configuration or class/method
level.
- **Programmatic Transaction Management**: Managing transactions using Spring’s
`PlatformTransactionManager` and `TransactionTemplate` classes,
giving more control and flexibility but
increasing complexity.

### Advanced Hibernate Questions

1. **What is the difference between first-level and second-level cache in


Hibernate?**

- **First-Level Cache**: The session-level cache that stores entities during a


session. It is mandatory and associated with the `Session` object.
- **Second-Level Cache**: The session-factory-level cache that stores entities
across multiple sessions. It is optional and configured using cache providers
(e.g., EHCache, Infinispan).

2. **Explain the concept of Hibernate Interceptor and its use cases.**

- **Hibernate Interceptor**: An interface used to intercept and modify the


behavior of Hibernate operations such as save, update, delete, and load. Use cases
include:
- **Auditing**: Recording changes to entities.
- **Logging**: Logging operations performed by Hibernate.
- **Validation**: Enforcing custom validation logic before database
operations.

3. **What are the different fetching strategies in Hibernate?**

- **Fetching Strategies**:
- **Immediate/ Eager Fetching**: Data is fetched immediately.
- **Lazy Fetching**: Data is fetched on demand when accessed.
- **Batch Fetching**: Fetches multiple records in a single query to avoid
multiple selects.
- **Select Fetching**: Executes a separate select statement for each item.
- **Subselect Fetching**: Uses a subselect query to load entities.
- **Join Fetching**: Uses a single join query to load related entities.

4. **What is the difference between `Session.save()` and `Session.persist()` in


Hibernate?**

- **Session.save()**: Immediately inserts a record into the database and returns


the generated identifier. It assigns an identifier to the entity if it doesn’t
already have one.
- **Session.persist()**: Only makes a transient instance persistent but does not
guarantee the immediate execution of an insert query.
It does not return the generated
identifier and works within the transaction boundaries.

### Advanced Frontend Questions

1. **Explain the concept of Virtual DOM in React.**

- **Virtual DOM**: A lightweight representation of the real DOM that React uses
to optimize rendering.
When the state of a component changes, React
creates a new virtual DOM tree and compares it with the previous one (diffing).
It then updates the real DOM with only the changes
(reconciliation), improving performance.

2. **What is Redux and how does it work in a React application?**

- **Redux**: A state management library for JavaScript applications, often used


with React.
It provides a centralized store for the entire application
state, allowing predictable state transitions.
- **Core Principles**:
- **Single Source of Truth**: The state of the application is stored in a
single object.
- **State is Read-Only**: The state can only be changed by dispatching
actions.
- **Changes are Made with Pure Functions**: Reducers specify how the state
changes in response to actions, ensuring immutability and predictability.

3. **What is the difference between class components and functional components in


React?**

- **Class Components**: ES6 classes that extend `React.Component` and have a


render method. They can have local state and lifecycle methods.
- **Functional Components**: Functions that return React elements.
They can use hooks (e.g.,
`useState`, `useEffect`) to manage state and side effects, making them more concise
and easier to understand.
4. **Explain Vue.js reactivity system.**

- **Vue.js Reactivity System**: Allows Vue to detect changes to the state and
update the DOM accordingly. It uses getters and setters to track dependencies and
notify watchers when data changes.
- **Mechanisms**:
- **Dependency Tracking**: Collects dependencies during the render phase.
- **Reactivity**: When data changes, Vue notifies all dependent components to
re-render.

### Advanced Database Questions

1. **Explain the concept of ACID properties in databases.**

- **ACID Properties**:
- **Atomicity**: Ensures that all operations within a transaction are
completed; if not, the transaction is aborted.
- **Consistency**: Ensures that a transaction brings the database from one
valid state to another.
- **Isolation**: Ensures that the execution of transactions concurrently does
not affect their outcome.
- **Durability**: Ensures that once a transaction is committed, it remains so,
even in the event of a system failure.

2. **What is the difference between horizontal and vertical scaling in databases?**

- **Horizontal Scaling**: Adding more machines to handle more data (scaling


out). Often used with distributed databases.
- **Vertical Scaling**: Adding more resources (CPU, RAM) to the existing machine
(scaling up). Often used with single-node databases.

3. **Explain database indexing and its types.**

- **Database Indexing**: A technique used to improve the speed of data


retrieval.
- **Types**:
- **B-Tree Index**: Balanced tree structure, commonly used in relational
databases.
- **Hash Index**: Uses a hash table, providing fast access for equality
searches.
- **Bitmap Index**: Uses bitmaps for indexing, useful in read-heavy
environments with low cardinality columns.
- **Full-Text Index**: Indexes text data for efficient text searches.
- **Spatial Index**: Used for indexing spatial data.

4. **What is a NoSQL database and when would you use one?**

- **NoSQL Database**: A non-relational database designed for distributed data


storage and high performance.
Types include document databases, key-value stores, wide-column stores,
and graph databases.
- **Use Cases**:
- **Scalability**: Need to handle large volumes of data with horizontal
scaling.
- **Flexibility**: Need for a flexible schema that can evolve.
- **Performance**: Need for high-speed reads and writes.
- **Complex Data Structures**: Need to handle complex, hierarchical, or
unstructured data.
### Behavioral and Situational Questions

1. **Describe a time when you had to learn a new technology quickly for a project.
How did you approach it?**

- **Answer**: "In my previous role, we decided to migrate to a microservices


architecture, and I had to learn Docker and Kubernetes quickly.
I started with online tutorials and documentation, set up a local
development environment, and built a few sample projects.
I also attended workshops and joined relevant forums to deepen my
understanding. By the end of the week, I was able to contribute effectively to the
project."

2. **How do you handle conflicts within your team?**

- **Answer**: "I believe in open communication and addressing conflicts early. I


ensure that all parties have a chance to express their views and understand each
other's perspectives.
I look for common ground and work towards a solution that is acceptable to
everyone. If necessary, I involve a neutral third party to mediate the discussion."

3. **Give an example of how you improved a system’s performance.**

- **Answer**: "In one project, I noticed that our application’s response time
was slow during peak hours.
I conducted a performance analysis and identified that the
database queries were a bottleneck.
I optimized the queries, added appropriate indexes, and
implemented caching for frequently accessed data.
This reduced the response time by 50% and improved user
satisfaction."

4. **Describe a situation where you disagreed with a decision made by your manager.
How did you handle it?**

- **Answer**: "There was a time when my manager decided to use a particular


technology stack that I believed was not the best fit for our project.
I scheduled a meeting with him and presented my concerns along with data and
examples. I proposed an alternative solution and explained the benefits.
Although we initially disagreed, my manager appreciated my input and we
eventually decided on a hybrid approach that incorporated elements from both our
suggestions."

5. **How do you ensure code quality in your projects?**

- **Answer**: "I ensure code quality through multiple practices such as code
reviews, automated testing, continuous integration, and adhering to coding
standards.
I encourage my team to write clean, maintainable code and to follow best
practices such as SOLID principles. I also use static code analysis tools to catch
potential issues early."

These advanced questions and answers should help you prepare thoroughly for a Java
Fullstack Developer interview.
Make sure to understand each concept deeply and be ready to discuss your
experiences and provide examples during the interview.
Certainly! Here are advanced questions and answers covering Spring Boot, Angular,
and Java collections, including both basic and advanced concepts, along with coding
questions.

### Spring Boot Questions

1. **Explain the difference between `@SpringBootApplication` and


`@EnableAutoConfiguration`.**

- **`@SpringBootApplication`**: A convenience annotation that combines


`@Configuration`, `@EnableAutoConfiguration`, and `@ComponentScan` with their
default attributes.
- **`@EnableAutoConfiguration`**: Enables Spring Boot’s auto-configuration
mechanism, which attempts to automatically configure your
Spring application based on
the jar dependencies you have added.

2. **How does Spring Boot handle externalized configuration?**

- Spring Boot allows you to externalize your configuration so you can work with
the same application code in different environments.
It uses `application.properties` or `application.yml` files, and supports
properties defined in the following locations, in order of precedence:
- Command line arguments.
- Java System properties.
- `application.properties` or `application.yml` in the classpath.
- Application properties outside the packaged jar (in `config/` or the same
directory as the jar).
- Config Server.

3. **What are Spring Boot Starters and how do they help in application development?
**

- **Spring Boot Starters**: Pre-configured sets of dependencies designed to


simplify the setup of new Spring applications.
For example, `spring-boot-starter-web` includes dependencies for Spring MVC,
REST, and Jackson.
- **Benefits**:
- Simplifies dependency management.
- Ensures compatibility between dependencies.
- Reduces boilerplate configuration.

4. **Explain the usage of `@RestController` and `@Controller` in Spring Boot.**

- **`@RestController`**: A convenience annotation that combines `@Controller`


and `@ResponseBody`. It is used for creating RESTful web services.
- **`@Controller`**: Indicates that the class is a Spring MVC controller. It is
used to mark a class as a web controller capable of handling requests and returning
views.

5. **Describe the Spring Boot Actuator and its benefits.**

- **Spring Boot Actuator**: Provides production-ready features to help monitor


and manage applications.
It includes a variety of endpoints to
gather metrics, health checks, and application information.
- **Benefits**:
- Built-in health checks and metrics.
- Integration with monitoring tools.
- Customizable endpoints for application management.

### Angular Questions

1. **What is Angular and what are its main features?**

- **Angular**: A platform and framework for building single-page client


applications using HTML, CSS, and TypeScript. It is maintained by Google.
- **Main Features**:
- **Components**: Building blocks of Angular applications.
- **Templates**: Define the view for Angular components.
- **Data Binding**: Synchronizes data between model and view.
- **Dependency Injection**: Manages service dependencies.
- **Directives**: Extend HTML with custom attributes and elements.
- **Routing**: Allows navigation between views.

2. **Explain Angular Services and Dependency Injection.**

- **Angular Services**: Singleton objects that encapsulate business logic or


data access. They are defined using the `@Injectable` decorator.
- **Dependency Injection (DI)**: A design pattern used to implement IoC
(Inversion of Control), where dependencies are injected rather than created by the
class itself.
Angular uses DI to provide
services and other dependencies to components and other services.

3. **What is Angular CLI and how does it help in development?**

- **Angular CLI (Command Line Interface)**: A tool that automates the setup and
management of Angular projects.
It provides
commands for generating components, services, and modules, running tests, building
the application, and serving it locally.
- **Benefits**:
- Simplifies project setup.
- Enforces best practices.
- Automates repetitive tasks.

4. **Explain the concept of Angular Modules.**

- **Angular Modules (NgModules)**: Containers for a cohesive block of code


dedicated to an application domain, a workflow, or a closely related set of
capabilities.
Defined using the
`@NgModule` decorator.
- **Key Properties**:
- **declarations**: List of components, directives, and pipes.
- **imports**: List of modules to import.
- **providers**: List of services.
- **bootstrap**: Main application view.

5. **What is Angular Change Detection and how does it work?**

- **Change Detection**: The mechanism Angular uses to check the state of the
application and update the view when the state changes.
It runs every time there is an asynchronous
event (e.g., user input, HTTP response).
- **How it works**:
- Angular creates a change detector for each component.
- The change detector checks the component’s data bindings for changes.
- If changes are detected, Angular updates the view accordingly.

### Java Collections Questions

#### Basic Collections Questions

1. **What are the main interfaces in the Java Collections Framework?**

- **Collection**: The root interface of the framework, representing a group of


objects.
- **List**: An ordered collection that allows duplicate elements (e.g.,
`ArrayList`, `LinkedList`).
- **Set**: A collection that does not allow duplicate elements (e.g., `HashSet`,
`TreeSet`).
- **Queue**: A collection used to hold multiple elements prior to processing
(e.g., `LinkedList`, `PriorityQueue`).
- **Map**: An object that maps keys to values, cannot contain duplicate keys
(e.g., `HashMap`, `TreeMap`).

2. **Explain the difference between `ArrayList` and `LinkedList`.**

- **ArrayList**:
- Backed by an array.
- Provides fast random access.
- Slow at insertions and deletions (except at the end of the list) due to
shifting of elements.
- **LinkedList**:
- Backed by a doubly-linked list.
- Provides fast insertions and deletions.
- Slow at random access (sequential access is faster).

3. **What is a `HashMap` and how does it work?**

- **`HashMap`**: A map based on a hash table. It stores key-value pairs and


allows for fast retrieval based on the key.
- **How it works**:
- Uses a hash function to compute an index for a key.
- Stores the key-value pair in a bucket at the computed index.
- Handles collisions using chaining (linked list) or open addressing.

4. **What is the difference between `HashSet` and `TreeSet`?**

- **`HashSet`**:
- Uses a hash table for storage.
- Provides constant-time performance for basic operations.
- Does not maintain any order of elements.
- **`TreeSet`**:
- Uses a Red-Black tree for storage.
- Provides log-time performance for basic operations.
- Maintains elements in natural order or by a specified comparator.

5. **Explain the concept of `Iterator` and `ListIterator`.**

- **`Iterator`**: An interface that provides methods to iterate over a


collection (`hasNext()`, `next()`, `remove()`).
- **`ListIterator`**: An extension of `Iterator` specific to lists.
Provides additional methods (`hasPrevious()`,
`previous()`, `add()`, `set()`) to traverse the list in both directions and modify
it.

#### Advanced Collections Questions

1. **What are the differences between `ConcurrentHashMap` and


`Collections.synchronizedMap()`?**

- **`ConcurrentHashMap`**:
- Provides better concurrency by allowing concurrent read and write
operations.
- Uses a segmented locking mechanism to reduce contention.
- Suitable for highly concurrent environments.
- **`Collections.synchronizedMap()`**:
- Wraps a `HashMap` with synchronized methods.
- Synchronizes the entire map on each operation, leading to more contention.
- Suitable for low concurrency environments.

2. **How does `CopyOnWriteArrayList` work and when would you use it?**

- **`CopyOnWriteArrayList`**: A thread-safe variant of `ArrayList` that creates


a new copy of the underlying array on each modification.
- **Usage**:
- Suitable for applications with more read operations than write operations.
- Provides thread safety without the need for synchronization during reads.

3. **Explain the `Comparator` and `Comparable` interfaces.**

- **`Comparable`**:
- Used to define the natural ordering of objects.
- The class itself implements `Comparable` and overrides the `compareTo()`
method.
- **`Comparator`**:
- Used to define custom orderings for objects.
- A separate class implements `Comparator` and overrides the `compare()`
method.
- **Differences**:
- `Comparable` is used when there is a single, natural order.
- `Comparator` is used for multiple or custom orders.

4. **What is a `WeakHashMap` and how is it different from a `HashMap`?**

- **`WeakHashMap`**: A map that uses weak references for its keys.


- **Differences**:
- Entries in a `WeakHashMap` are automatically removed when the key is no
longer in use (i.e., there are no strong references to the key).
- Suitable for caches or maps where entries should be removed automatically to
prevent memory leaks.

5. **

How does `PriorityQueue` work in Java?**

- **`PriorityQueue`**:
- A queue that orders its elements according to their natural ordering or by a
specified comparator.
- Implements a binary heap structure.
- Ensures that the element with the highest priority is always at the head of
the queue.
### Coding Questions

1. **Write a Java program to reverse a `LinkedList` without using any built-in


methods.**

```java
class Node {
int data;
Node next;

Node(int data) {
this.data = data;
this.next = null;
}
}

public class LinkedList {


Node head;

public void reverse() {


Node prev = null;
Node current = head;
Node next = null;
while (current != null) {
next = current.next;
current.next = prev;
prev = current;
current = next;
}
head = prev;
}

public void printList() {


Node node = head;
while (node != null) {
System.out.print(node.data + " ");
node = node.next;
}
System.out.println();
}

public static void main(String[] args) {


LinkedList list = new LinkedList();
list.head = new Node(1);
list.head.next = new Node(2);
list.head.next.next = new Node(3);
list.head.next.next.next = new Node(4);

System.out.println("Original List:");
list.printList();

list.reverse();

System.out.println("Reversed List:");
list.printList();
}
}
```
2. **Write a Java program to implement a LRU Cache.**

```java
import java.util.*;

class LRUCache<K, V> {


private final int capacity;
private final Map<K, V> map;
private final LinkedList<K> accessOrder;

public LRUCache(int capacity) {


this.capacity = capacity;
this.map = new HashMap<>();
this.accessOrder = new LinkedList<>();
}

public V get(K key) {


if (!map.containsKey(key)) {
return null;
}
accessOrder.remove(key);
accessOrder.addFirst(key);
return map.get(key);
}

public void put(K key, V value) {


if (map.containsKey(key)) {
accessOrder.remove(key);
} else if (map.size() == capacity) {
K oldestKey = accessOrder.removeLast();
map.remove(oldestKey);
}
accessOrder.addFirst(key);
map.put(key, value);
}

public static void main(String[] args) {


LRUCache<Integer, String> cache = new LRUCache<>(3);
cache.put(1, "one");
cache.put(2, "two");
cache.put(3, "three");
System.out.println(cache.get(1)); // prints "one"
cache.put(4, "four"); // removes key 2
System.out.println(cache.get(2)); // prints "null"
}
}
```

3. **Write a Java program to find the first non-repeated character in a string.**

```java
import java.util.*;

public class FirstNonRepeatedCharacter {


public static Character findFirstNonRepeatedChar(String str) {
Map<Character, Integer> charCount = new LinkedHashMap<>();
for (char c : str.toCharArray()) {
charCount.put(c, charCount.getOrDefault(c, 0) + 1);
}
for (Map.Entry<Character, Integer> entry : charCount.entrySet()) {
if (entry.getValue() == 1) {
return entry.getKey();
}
}
return null;
}

public static void main(String[] args) {


String str = "swiss";
Character result = findFirstNonRepeatedChar(str);
if (result != null) {
System.out.println("First non-repeated character: " + result);
} else {
System.out.println("No non-repeated character found.");
}
}
}
```

These questions and answers cover advanced topics in Spring Boot, Angular, and Java
collections, along with coding exercises that demonstrate your ability to solve
practical problems in Java.
Good luck with your interview preparation!

Sure, let's dive into the detailed explanations of the questions with appropriate
code examples.

### 1. Why is Java not 100% Object-oriented?

Java is not considered 100% object-oriented because it uses primitive data types
(such as `int`, `char`, `boolean`, etc.) which are not objects.

Example:
```java
public class PrimitiveExample {
public static void main(String[] args) {
int x = 5; // Primitive type, not an object
Integer y = 10; // Wrapper class, an object
}
}
```

### 2. Why are pointers not used in Java?

Pointers are not used in Java to enhance security and simplify memory management.
Java uses references instead of pointers.

Example:
```java
public class ReferenceExample {
public static void main(String[] args) {
String str = "Hello, World!";
System.out.println(str); // Using reference to an object
}
}
```
### 3. What is a JIT compiler in Java?

The JIT (Just-In-Time) compiler compiles bytecode into native machine code at
runtime for performance optimization.

Example:
```java
public class JITExample {
public static void main(String[] args) {
for (int i = 0; i < 1000000; i++) {
method();
}
}

public static void method() {


// Some code
}
}
```

### 4. Why is String immutable in Java?

Strings are immutable for security, performance, thread-safety, and hashcode


caching reasons.

Example:
```java
public class StringExample {
public static void main(String[] args) {
String str = "Hello";
str.concat(" World");
System.out.println(str); // Outputs "Hello"
}
}
```

### 5. What is a deadlock in Java and how to create it?

A deadlock occurs when two or more threads are blocked forever, each waiting for
the other to release a resource.

Example:
```java
public class DeadlockExample {
public static void main(String[] args) {
final Object resource1 = "resource1";
final Object resource2 = "resource2";

Thread t1 = new Thread(() -> {


synchronized (resource1) {
System.out.println("Thread 1: Locked resource 1");
try { Thread.sleep(100); } catch (InterruptedException e) {}
synchronized (resource2) {
System.out.println("Thread 1: Locked resource 2");
}
}
});

Thread t2 = new Thread(() -> {


synchronized (resource2) {
System.out.println("Thread 2: Locked resource 2");
try { Thread.sleep(100); } catch (InterruptedException e) {}
synchronized (resource1) {
System.out.println("Thread 2: Locked resource 1");
}
}
});

t1.start();
t2.start();
}
}
```

### 6. Can you override a private or static method?

No, you cannot override a private or static method. Private methods are not visible
to subclasses, and static methods belong to the class.

Example:
```java
class Parent {
private void privateMethod() {
System.out.println("Private method in Parent");
}

static void staticMethod() {


System.out.println("Static method in Parent");
}
}

class Child extends Parent {


private void privateMethod() {
System.out.println("Private method in Child");
}

static void staticMethod() {


System.out.println("Static method in Child");
}
}

public class OverrideExample {


public static void main(String[] args) {
Parent.staticMethod(); // Calls Parent's static method
Child.staticMethod(); // Calls Child's static method
}
}
```

### 7. Does "finally" always execute in Java?

The `finally` block always executes when the `try` block exits, except in certain
cases like JVM crash or `System.exit()` call.

Example:
```java
public class FinallyExample {
public static void main(String[] args) {
try {
System.out.println("In try block");
} finally {
System.out.println("In finally block");
}
}
}
```

### 8. How Can You Make a Class Immutable?

To make a class immutable, declare it as `final`, make all fields `private` and
`final`, initialize fields via constructor, and do not provide setters.

Example:
```java
public final class ImmutableClass {
private final int value;
private final List<String> list;

public ImmutableClass(int value, List<String> list) {


this.value = value;
this.list = new ArrayList<>(list);
}

public int getValue() {


return value;
}

public List<String> getList() {


return new ArrayList<>(list);
}
}
```

### 9. How can we make a class singleton?

A class can be made singleton by ensuring that only one instance of the class is
created and providing a global point of access to that instance.

**Eager Initialization:**
```java
public class Singleton {
private static final Singleton INSTANCE = new Singleton();

private Singleton() {}

public static Singleton getInstance() {


return INSTANCE;
}
}
```

### 10. How to break a Singleton pattern?

A singleton pattern can be broken using reflection, serialization, or multiple


class loaders.

**Breaking with Reflection:**


```java
import java.lang.reflect.Constructor;

public class SingletonBreaker {


public static void main(String[] args) throws Exception {
Singleton instance1 = Singleton.getInstance();
Constructor<Singleton> constructor =
Singleton.class.getDeclaredConstructor();
constructor.setAccessible(true);
Singleton instance2 = constructor.newInstance();

System.out.println(instance1 == instance2); // prints false


}
}
```

### 11. Does Java support multiple inheritance?

Java does not support multiple inheritance for classes but supports it through
interfaces.

Example:
```java
interface InterfaceA {
void methodA();
}

interface InterfaceB {
void methodB();
}

class MultipleInheritanceExample implements InterfaceA, InterfaceB {


public void methodA() {
System.out.println("Method A");
}

public void methodB() {


System.out.println("Method B");
}

public static void main(String[] args) {


MultipleInheritanceExample example = new MultipleInheritanceExample();
example.methodA();
example.methodB();
}
}
```

### 12. Access a non-static variable in a static context

To access a non-static variable in a static context, create an instance of the


class.

Example:
```java
public class Example {
private int nonStaticVariable = 10;

public static void main(String[] args) {


Example instance = new Example();
System.out.println(instance.nonStaticVariable);
}
}
```

### 13. Is it possible to load a class by two ClassLoaders?

Yes, it is possible. Each class loader defines its own namespace.

Example:
```java
public class CustomClassLoader extends ClassLoader {
// Custom class loader implementation
}

public class ClassLoaderExample {


public static void main(String[] args) throws ClassNotFoundException {
CustomClassLoader loader1 = new CustomClassLoader();
CustomClassLoader loader2 = new CustomClassLoader();

Class<?> class1 = loader1.loadClass("ExampleClass");


Class<?> class2 = loader2.loadClass("ExampleClass");

System.out.println(class1 == class2); // prints false


}
}
```

### 14. What is a marker interface?

A marker interface is an interface with no methods or fields, used to mark a class


with a specific property.

Example:
```java
public interface MarkerInterface {
// No methods or fields
}

public class MarkerExample implements MarkerInterface {


public static void main(String[] args) {
MarkerExample example = new MarkerExample();
if (example instanceof MarkerInterface) {
System.out.println("This is a marker interface instance.");
}
}
}
```

### 15. Best candidate for the HashMap Key?

The best candidate for a `HashMap` key is an immutable object that properly
implements the `hashCode` and `equals` methods.

Example:
```java
public class HashMapExample {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("key1", "value1");
System.out.println(map.get("key1")); // Outputs "value1"
}
}
```

### 16. Can we use a default constructor of a class even if an explicit constructor
is defined?

No, if a class defines any explicit constructor, the compiler does not generate a
default (no-argument) constructor.
You must explicitly define a no-argument constructor if you want to use one.

Example:
```java
public class ConstructorExample {
public ConstructorExample(int value) {
// Explicit constructor
}

// Define a no-argument constructor explicitly


public ConstructorExample() {}

public static void main(String[] args) {


ConstructorExample example = new ConstructorExample();
}
}
```

### 17. If two threads have the same priority, which thread will be executed first?

If two threads have the same priority, the thread scheduler decides which thread to
run first. The behavior is not guaranteed and can be platform-dependent.

Example:
```java
public class ThreadPriorityExample {
public static void main(String[] args) {
Thread t1 = new Thread(() -> System.out.println("Thread 1"));
Thread t2 = new Thread(() -> System.out.println("Thread 2"));

t1.setPriority(Thread.NORM_PRIORITY);
t2

.setPriority(Thread.NORM_PRIORITY);

t1.start();
t2.start();
}
}
```

### 18. Can we serialize static variables in Java?

No, static variables belong to the class and are not part of any specific instance.
They are not serialized as part of the object's state.

Example:
```java
import java.io.*;

public class StaticSerializationExample implements Serializable {


private static int staticVariable = 42;

public static void main(String[] args) {


StaticSerializationExample example = new StaticSerializationExample();

try (ObjectOutputStream oos = new ObjectOutputStream(new


FileOutputStream("example.ser"))) {
oos.writeObject(example);
} catch (IOException e) {
e.printStackTrace();
}

staticVariable = 100;

try (ObjectInputStream ois = new ObjectInputStream(new


FileInputStream("example.ser"))) {
StaticSerializationExample deserializedExample =
(StaticSerializationExample) ois.readObject();
System.out.println(staticVariable); // Outputs 100, not 42
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
}
```
a
These explanations and code examples should help you understand the concepts better
and prepare for your interview. Good luck!

19. Can we print anything in console without main method in java?


-- Yes, using static block.

20. Can we have multiple static blocks? why?


--> Yes we can have. To initialize static data members we can use static
initializer block.

21. Can we have multiple finally blocks in java?


--> No.

22. Set vs Arraylist difference.


-->

23. Can we include class as a key in hashmap?


--> So basically class in a mutable object and in collections we can only have
immutable objects, that is why we are incorporating wrapper class objects because
wrapper class is immutable.
so class is mutable object but still we ca include class as a key by
overriding hashcode and equals method, as class is mutable object so there will be
different hashcode generated
once data of object is changed. so we need to be sure that our class object
returns single only same hashcode and equals everytime the class object is passed
as a key. So we can do this but
we compulsorily have to override hashcode and equals method in our code.
24. Reflection in java?
--> It's a feature that allows us to modify the behaviour of methods classes and
interface in java. There are many methods like getClass, getConstructor, getMethod
due to which we can modify the behavior
and write our code accordingly.

25. Can functional interface extend another interface?


--> It can only inherit interface that has static and default methods and not
interface have abstract methods, because if it extends that interface then rule of
SAM interface will be violated.

26. What are Idempotent methods and why we use them?


--> So these are nothing but if u are trying to request same type of data, it is
Idempotent means identical requests are made to access the same resource many
times. So these are the duplicate requests
you are making multiple times. So that is y we have get, put and delete http
methods, which will not chnage the state of server even if multiple times the same
resource is being requested.

27. Difference b/w @RequestParam and @PathVariable


--> Basically @RequestParam is like a key value pair which we pass after ? in url
name=2 and this will be captured and @PathVariable is if u pass only single value
like slash(/) value that will be captured in it.

28. What is @Configuration`annotation?


--> so if we want to write particular configuration, then we can annotate a class
with this annotation and write configurations inside it.

https://www.youtube.com/playlist?listPL0zysOflRCek8kmc_jYl_6C7tpud7U2V_}&locale=en-
us

JAVA
Load Balancer, sdlc, hashmap, strings, exeption handling, abstraction,
encapsulation, streams, marker interface, actuators,quarkus, pc register, jvm,
profiles, native vs hql

Anagram
missing number from unsorted list
sort custom objects using java 8
object class and it's methods
multithreading
hashset vs arraylist
write api to retreive userdata based on userId
Autowire userName and userPassword and explain it in terms of dependency injection
implement 2 Rest Templates with timeout 30 and 50 seconds
cyclic dependency in springboot and how to resolve
how to extract unique keys from json object and it's return type should be set of
strings
comparator vs comparable and implement code for each
how to manage and handle exceptions
method hiding code and explain which method will be invoked
what is concurrent exception and how to fix it?

Design Patterns
If there is multithreaded environment, how will you achieve synchronisation.
why cache threadpool is used? and how multiple request will be handled?
configurtion setup to deploy service
how to make hashmap synchronized
count occurence of each character in string using stream api
how did you handle unit test coverage
how did you optimize code?
how to make objects unreferenced for garbage collection?
what are steps taken in case of pipeline fails?
maximum length of array
sort given maps using comparator
annotations in springboot
how do microservices communicate
advantages and disadvantages of microservices
predict output of exception handling code.
streams functions explainantion
why functional nterface has only one method?
solid principles code is breaking and fix it.(Find which solid principle this code
breaks and then correct it)
solve given problem using filter and map
transaction mamangement related questions(if parent method calls a child method
with issue will parent method work?)--propagations
REST API(optional pathVariables, requestparams)
sql queries regarding joins(all are imp queries in sql)
why stored procedures are used?
Thread Local, executor framework, completable futures
Aware interfaces, Bean Lifecycle
how to inject prototype bean into singleton?
Different architectures in microservices
how to print odd even no.s using executor service
what are recent improvements in java8 memory management?
how to configure different ports for differnt environments?
print player's corresponding highestv score from his multiple scores.
how to monitor multiple microservices?

kafka: Concept and coding


what will happen if the size limit is reached in kafka?
how will you handle when consumer can't process messages?
if queue is down how wll messages be processed
which colletion will u use to access list of integers.
how do we do logging in our projects

pinacle

Angular
Lifecycle hooks

You might also like