JavaHacker

JavaHacker Java Interview Questions | Coder | Web Development

HashMap internal working flow
14/06/2026

HashMap internal working flow

03/01/2026

01/01/2026
How many people will fail this simple Quiz πŸ‘‡
28/12/2025

How many people will fail this simple Quiz πŸ‘‡

28/12/2025

27/12/2025



Spring Security Architecture – Complete Flow ExplainedSpring Security may look complex, but its architecture follows a v...
26/12/2025

Spring Security Architecture – Complete Flow Explained

Spring Security may look complex, but its architecture follows a very clear flow.
Understanding this flow is crucial for interviews and real-world projects.

Let’s break it down step by step πŸ‘‡
1. Client Sends Request
A user sends an HTTP request (login or API access) from browser/mobile/Postman.
2. Security Filter Chain
Before reaching your controller, the request passes through Spring Security filters.
Example filters:
UsernamePasswordAuthenticationFilter
JwtAuthenticationFilter
πŸ‘‰ Filters intercept every request.
3. Authentication Manager
The filter delegates authentication to AuthenticationManager.
βœ” Responsible for validating user identity
βœ” Delegates work to AuthenticationProvider
4. Authentication Provider
This is where actual verification happens.
Calls UserDetailsService
Validates credentials using PasswordEncoder
Returns authenticated Authentication object
5. UserDetailsService
Loads user data from:
Database
LDAP
In-memory store
Returns a UserDetails object.
6. SecurityContextHolder
After successful authentication: βœ” User details
βœ” Roles / Authorities
are stored in SecurityContextHolder.
πŸ‘‰ This context is available throughout the request lifecycle.
7. Authorization (Access Decision)
Spring Security checks:
User roles
Permissions
Method-level security
πŸ”Ή Components involved:
AccessDecisionManager
AccessDecisionVoter
,
8. Access Granted or Denied
βœ… If authorized β†’ request reaches controller
❌ If not β†’ 403 Forbidden or 401 Unauthorized




πŸ”₯ Difficult Java Technical Questions – Explained Simply1. Why is String immutable in Java?Because: βœ” Thread-safe by desi...
26/12/2025

πŸ”₯ Difficult Java Technical Questions – Explained Simply

1. Why is String immutable in Java?
Because: βœ” Thread-safe by design
βœ” Improves performance via String Pool
βœ” Enhances security (class loading, DB URLs)
🧠 Key Insight:
Immutability allows JVM to safely reuse String objects.

2. Difference between == and .equals()?
== β†’ compares memory referenceequals() β†’ compares content
🧠 Interview Twist:
If .equals() is not overridden, it behaves like ==.

3. Why is HashMap not thread-safe?
Because multiple threads can: βœ” Modify structure simultaneously
βœ” Cause infinite loops during resize (pre-Java 8)
🧠 Solution:
Use ConcurrentHashMap for concurrency.

4. How does volatile work internally?
βœ” Ensures visibility across threads
βœ” Prevents instruction reordering
❌ Does NOT guarantee atomicity
🧠 Example:
volatile β‰  thread-safe increment

5. Why doesn’t Java support multiple inheritance?
To avoid Diamond Problem πŸ’Ž
🧠 Workaround:
Java supports multiple inheritance via interfaces.

6. Difference between Comparable and Comparator?
Comparable β†’ natural ordering (inside class)
Comparator β†’ custom ordering (external)
🧠 Real Use:
Sorting by name, salary, date, etc.

Spring Boot Project Structure (STS) – Explained SimplyA clean project structure is the foundation of a scalable & mainta...
25/12/2025

Spring Boot Project Structure (STS) – Explained Simply
A clean project structure is the foundation of a scalable & maintainable Spring Boot application.
Here’s how a standard Spring Boot project is organized in Spring Tool Suite (STS) πŸ‘‡
πŸ“ src/main/java
➑️ Contains all Java source code
controller
Handles HTTP requests (, , )
service
Contains business logic
Keeps controller clean and reusable
repository
Used for database operations
Typically extends JpaRepository
model / entity
Represents database tables using
exception
Centralized exception handling
Example: GlobalExceptionHandler
πŸ“ src/main/resources
➑️ Configuration & static files
application.properties / application.yml
static/ (css, js, images)
templates/ (Thymeleaf, if used)
πŸ“ src/test/java
➑️ Unit & integration test cases
SpringBootProjectApplicationTests
πŸ“„ pom.xml
➑️ Manages dependencies & build configuration


25/12/2025

Address

Hyderabad
500003

Website

Alerts

Be the first to know and let us send you an email when JavaHacker posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Shortcuts

Share