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

Full-Stack Java Interview Notes

These revision notes cover essential concepts for a Full-Stack Java interview, focusing on Java, Spring Boot, WebFlux, Angular, REST, Microservices, AWS, and DevOps. Key topics include core Java principles, Spring framework fundamentals, reactive programming with WebFlux, and microservices architecture patterns. The document also includes practical coding questions, system design basics, and a checklist for interview preparation.

Uploaded by

dreamers.nerd
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)
16 views19 pages

Full-Stack Java Interview Notes

These revision notes cover essential concepts for a Full-Stack Java interview, focusing on Java, Spring Boot, WebFlux, Angular, REST, Microservices, AWS, and DevOps. Key topics include core Java principles, Spring framework fundamentals, reactive programming with WebFlux, and microservices architecture patterns. The document also includes practical coding questions, system design basics, and a checklist for interview preparation.

Uploaded by

dreamers.nerd
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

Full-Stack Java Interview Revision Notes

(In-Depth)
These notes are tailored specifically to the job description you shared: Java, Spring Boot, WebFlux,
Angular, REST, Microservices, AWS, DevOps basics, and architectural thinking.

1. Core Java & J2EE Concepts (Deep Revision)

1.1 OOP Pillars (with examples)


Encapsulation: Wrapping data + methods (private fields, getters/setters). Prevents unintended
access.
Abstraction: Hiding complexity (interfaces, abstract classes). Focus on "what" not "how".
Inheritance: Code reusability; extends keyword; multi-level inheritance.
Polymorphism:
Compile-time (method overloading).
Runtime (method overriding + dynamic binding).

1.2 Important Java Concepts


Immutability (String, Wrapper classes, custom immutable class).
StringBuilder vs StringBuffer vs String.
Exception handling: Checked vs unchecked, try-with-resources.
Generics: Bounded types, wildcards, type erasure.
Functional Programming (Java 8+):
Lambda expressions.
Method references.
Streams API: map/filter/reduce, parallel streams.

1.3 Java Memory Model


Heap, Stack, Metaspace.
Garbage Collection (G1 GC in Java 11+).
Happens-before relationship.
1.4 Multithreading & Concurrency
Thread lifecycle.
Executors, ThreadPools.
Callable vs Runnable.
CompletableFuture.
Locks: ReentrantLock, ReadWriteLock.
Concurrency utilities: CountDownLatch, CyclicBarrier, Semaphore.

2. Primitive Types and Wrapper Classes

2.1 Primitive Types & Sizes

Type Size Range

byte 1 byte -128 to 127

short 2 bytes -32,768 to 32,767

int 4 bytes ~2.1B

long 8 bytes Huge

float 4 bytes 6-7 digits

double 8 bytes 15 digits

char 2 bytes Unicode

boolean JVM dependent

2.2 Wrapper Classes In-Depth


Immutable, final classes.
Autoboxing/unboxing pitfalls.
Integer caching (-128 to 127).
Useful methods: parseXXX, valueOf, compare, toString.
NullPointerException risk when unboxing.
3. Collections Framework (Advanced)

3.1 Core Interfaces


List, Set, Queue, Map.

3.2 List Implementations


ArrayList: Fast random access, resizing cost.
LinkedList: Fast insert/delete, slow random access.

3.3 Set Implementations


HashSet: Uses hashing; O(1) average.
LinkedHashSet: Maintains insertion order.
TreeSet: Sorted; O(log n).

3.4 Map Implementations


HashMap: Buckets + tree bins (Java 8). O(1) average.
LinkedHashMap: Predictable iteration.
TreeMap: Sorted, Red-Black Tree.
ConcurrentHashMap: Lock-striping, threadsafe.

3.5 Fail-Fast vs Fail-Safe Iterators


Fail-fast (ArrayList, HashMap) → ConcurrentModificationException.
Fail-safe (CopyOnWriteArrayList, ConcurrentHashMap).

3.6 Practical Questions


How HashMap works internally?
Hash collision handling?
Why Tree bins introduced in Java 8?
4. Spring Framework & Spring Boot (Core
Depth)

4.1 Spring Boot Core Concepts


Auto-configuration.
Starter dependencies.
Actuator endpoints.
Profiles.

4.2 DI & IoC


Bean lifecycle.
Bean scopes: singleton, prototype, request, session.
@Configuration, @Bean, @Component, @Service, @Repository.

4.3 REST API Fundamentals


@RestController, @RequestMapping.
HTTP methods semantics.
Content negotiation.
Exception handling:
@ControllerAdvice
@ExceptionHandler

4.4 Spring Boot Security Basics


Filters, AuthenticationManager, UserDetailsService.
JWT authentication.

5. Spring WebFlux & Reactive Programming


(High Importance!)

5.1 Why Reactive?


Handles thousands of concurrent requests.
Non-blocking I/O.

5.2 Core Types


Mono → 0 or 1 result.
Flux → 0…N results.

5.3 Operators
map, flatMap, switchMap, filter.
onErrorResume, retry.

5.4 WebFlux Handler vs Annotated Style


WebFlux supports Functional routing.

5.5 Thread Model


EventLoop, Netty.
No blocking calls! Blockhound helps detect blocking.

6. Microservices Architecture

6.1 Key Components


API Gateway.
Service Registry (Eureka).
Config Server.
Distributed tracing: Sleuth, Zipkin.
Circuit breakers (Resilience4j).

6.2 Patterns
Saga pattern.
CQRS.
Event-driven architectures.
6.3 REST Best Practices
Idempotency.
Pagination.
Rate limiting.

7. SOAP Web Services


WSDL.
XML-based.
JAX-WS.
JAXB for marshalling/unmarshalling.
Differences from REST:
Stateless vs stateful.
Lightweight JSON vs heavy XML.

8. Hibernate / JPA

8.1 Entity Mapping


@Entity, @Table, @Id.
@OneToOne, @OneToMany, @ManyToOne.

8.2 Caching
First-level cache (Session).
Second-level cache (ehcache).

8.3 N+1 Problem


Use @Fetch([Link]).
Use join fetch queries.
8.4 Transaction Management
@Transactional behaviour.
Propagation modes.

9. Angular + TypeScript

9.1 Angular Core Concepts


Components, Modules, Templates.
Services and Dependency Injection.
Reactive Forms vs Template Forms.
Lifecycle hooks (ngOnInit, ngOnDestroy ...).

9.2 TypeScript Essentials


Interfaces.
Union types.
Optional parameters.
Generics.

9.3 RxJS in Angular


Observables.
Subjects and BehaviourSubjects.
pipe(), map(), debounceTime(), mergeMap().

9.4 Angular Communication


Parent-child (Input/Output).
Service-based communication.
10. AWS Basics

10.1 AWS Services to Review


EC2, S3.
RDS.
Lambda.
CloudWatch.
IAM roles.
API Gateway.

10.2 CI/CD Overview


GitHub Actions pipelines.
Jenkins basics:
Pipeline stages.
Build → Test → Deploy.

11. Cards & Payments Domain (Bonus


Knowledge)

11.1 Concepts
Authorization.
Clearing.
Settlement.
Tokenization.
PCI-DSS compliance.

11.2 Common Flows


Card Transaction Lifecycle.
ISO 8583 message structure.
12. System Design Basics (Asked for senior
roles)
High-level design.
Load balancing.
Caching layer (Redis).
Database indexing.
Asynchronous messaging (Kafka, RabbitMQ).
Scaling strategies.

13. Interview Daily Revision Checklist

High Priority (Must Revise Tonight)


Java concurrency.
Collections internal working.
Spring Boot fundamentals.
WebFlux basics.
REST + Microservices patterns.
Angular fundamentals.
JPA/Hibernate mapping.

Medium Priority
AWS basics.
Jenkins pipeline.
SOAP fundamentals.
Cards/Payments concepts.

Low Priority (If extra time)


System design high-level.
Reactive streams deep internals.
End of Revision Notes

14. Visual Diagrams (ASCII for quick


understanding)

14.1 Spring Boot Architecture (High-Level)

+---------------------------+
| Client / Browser |
+-------------+-------------+
|
v
+---------------------------+
| Controller Layer |
| (REST Controllers) |
+-------------+-------------+
|
v
+---------------------------+
| Service Layer |
| (Business Logic) |
+-------------+-------------+
|
v
+---------------------------+
| Repository Layer |
| (JPA/Hibernate) |
+-------------+-------------+
|
v
+---------------------------+
| Database (SQL) |
+---------------------------+
14.2 Spring WebFlux (Reactive Flow)

Client Request
|
v
Netty Server
|
v
WebFlux Handler ---> Returns Mono/Flux ---> Event Loop
|
v
Reactive Repository (Mongo/R2DBC)

14.3 Microservices Interaction

+-------------+ +----------------+ +---------------+


| API | -----> | Service 1 | -----> | Database 1 |
| Gateway | +----------------+ +---------------+
+-------------+
| +----------------+ +---------------+
+-----------> | Service 2 | -----> | Database 2 |
+----------------+ +---------------+

14.4 Angular App Architecture

+-------------------------------+
| Angular App |
+-------------------------------+
| Components | Templates | CSS |
+-------------------------------+
| Services (Business Logic) |
+-------------------------------+
| HTTPClient -> REST API Calls |
+-------------------------------+
| RxJS Observables & Streams |
+-------------------------------+
15. One-Page Cheat Sheet (Quick Revision)

Java & Collections Cheat Sheet


HashMap → O(1), TreeMap → O(log n), LinkedHashMap → order maintained.
ConcurrentHashMap → thread-safe, lock-striping.
Immutability → Thread-safe & cached.
Streams → map(), filter(), reduce(), flatMap().

Concurrency Cheat Sheet


ExecutorService, CompletableFuture.
synchronized vs Lock vs Atomic types.
CountDownLatch = wait for tasks to complete.
Semaphore = limit resource access.

Spring Boot Cheat Sheet


@RestController vs @Controller.
@Autowired (DI), @Bean (manual bean).
Profiles = env-specific configs.
Actuator → health, metrics.

Spring WebFlux Cheat Sheet


Mono = 0/1 item.
Flux = 0…N items.
Non-blocking end-to-end.
Use map/flatMap, onErrorResume.

Microservices Cheat Sheet


Config Server, Eureka, Gateway.
Resilience4j: CircuitBreaker, Retry.
Log aggregation → ELK or Splunk.
Angular Cheat Sheet
Lifecycle hooks: ngOnInit, ngOnDestroy.
Data binding: {{ }}, @Input(), @Output().
RxJS: debounceTime, switchMap.

Hibernate Cheat Sheet


LAZY loading → preferred.
@Transactional → manages commits/rollbacks.
Avoid N+1 using join fetch.

AWS Basics
EC2 = virtual server.
S3 = storage.
RDS = relational database.
IAM = authentication/authorization.

If you want, I can also add mock interview Q&A, coding practice problems, architecture
whiteboard examples, or domain (Payments) flow diagrams. Just tell me!

16. Mock Interview Q&A (With Detailed


Answers)

Q1. Explain how HashMap works internally in Java.


Answer:
HashMap stores data as key-value pairs using an array of buckets. Each bucket stores a linked list or
a balanced tree (since Java 8) of nodes.
Steps:

1. HashMap computes hash(key) .


2. Uses (n-1) & hash to find bucket index.
3. If bucket empty → insert.
4. If collision → compare keys:
If same → overwrite.
Else:
Before Java 8 → linked list traversal.
Java 8+ → if list size > 8 → convert to Red-Black Tree for O(log n) lookup.
5. Resize when load factor > 0.75.

Interview Tip: Mention treeification and resizing to show depth.

Q2. Explain Spring WebFlux and why it's non-blocking.


Answer:
Spring WebFlux is built on Reactive Streams and uses Netty instead of Tomcat. It uses an event-
loop architecture, meaning a small number of threads handle many requests.

It relies on Mono (0/1) and Flux(0–n) types.


No blocking calls: everything is async.
Instead of waiting for DB/IO, it registers callbacks.
Event loop gets freed instantly.

This helps handle thousands of concurrent connections with fewer threads.

Interview Tip: Say that WebFlux is ideal for I/O-intensive microservices.

Q3. REST vs SOAP differences?


Answer:

Feature REST SOAP

Format JSON XML

Style Architectural Strict protocol

Performance Fast, lightweight Slower

Security OAuth/JWT WS-Security (enterprise-grade)

Use Case Web/mobile APIs Banking, telecom (transaction-heavy)


Interview Tip: Stress that SOAP excels in ACID compliance.

Q4. What is the difference between @Component,


@Service, @Repository?
Answer:
All are stereotype annotations but differ in intent:

@Component: Generic bean.


@Service: Business logic layer.
@Repository: DAO layer + translates DB exceptions into Spring DataAccessException.

Q5. How does @Transactional work internally?


Answer:

Uses AOP proxy around your method.


Before method call → opens/joins transaction.
After method returns → commit or rollback.
Rollback happens automatically for RuntimeExceptions.
Can configure rollbackFor for checked exceptions.

Q6. Explain Microservices patterns you know.


Answer:

1. Circuit Breaker (Resilience4j): Stops cascading failures.


2. API Gateway Pattern: Single entry point.
3. Config Server: Centralized configs.
4. Service Registry: Dynamic service discovery.
5. Saga Pattern: Distributed transactions across services.
6. CQRS: Separate read/write models.

Use cases matter → Mention them with examples.


Q7. What is the difference between [Link] vs
[Link]?
Answer:

map: Synchronous transformation.


1 input → 1 output.
flatMap: Asynchronous transformation.
1 input → multiple async outputs.

Example:

Flux<Integer> f = [Link](1,2)
.flatMap(i -> callAsyncAPI(i));

Q8. Angular: What are Observables and why used?


Answer:

Observables provide async stream handling.


Better than Promises because:
Support multiple values.
Can be cancelled.
Support powerful operators: debounceTime(), switchMap().

Used heavily in HTTP calls and reactive forms.

Q9. Explain Lazy Loading in Hibernate.


Lazy loading loads associated entities only when accessed.

Prevents unnecessary queries.


Achieved using proxies.

Problem: LazyInitializationException when session closes.


Solution:
Use JOIN FETCH .
Use OpenSessionInView filter.

Q10. Explain Payment Flow (Cards Domain).


Steps:

1. Authorization: Verify card + balance.


2. Authentication: 3DS, OTP.
3. Clearing: Batch processing between banks.
4. Settlement: Actual money transfer.

Important terms:

Issuer → Your bank.


Acquirer → Merchant bank.
Network → Visa/Mastercard.
Tokenization → Replace PAN with token.

17. Real Coding Questions (With Answers)

Q1. Write a Java 11 Stream program to find duplicates


in a list.

List<Integer> list = [Link](1,2,3,2,4,1);


Set<Integer> duplicates = [Link]()
.collect([Link](i -> i, [Link]()))
.entrySet().stream()
.filter(e -> [Link]() > 1)
.map([Link]::getKey)
.collect([Link]());
Q2. WebFlux: Write API returning list of users using
Flux.

@GetMapping("/users")
public Flux<User> getUsers() {
return [Link](); // Reactive Repo
}

Q3. Angular: Create a service calling backend API.

@Injectable({ providedIn: 'root' })


export class UserService {
constructor(private http: HttpClient) {}

getUsers(): Observable<User[]> {
return [Link]<User[]>(`/api/users`);
}
}

18. System Design: Sample High-Level Answer

Design a High-Scale Payment Processing System


Key Points:

1. API Gateway for routing.


2. Auth Service for authentication/tokenization.
3. Transaction Service (Idempotency!).
4. Ledger Service (event sourcing recommended).
5. Message broker (Kafka) for async flows.
6. Settlement Service for batch processing.
7. Database partitioning for scale.

Add diagram if you want.


Let me know if you want diagrams for system design, more Q&A, or coding questions!

You might also like