Summary of "Can You Answer These EPAM Java Spring Boot Questions? | 3 Yrs Mock Interview"
Summary of the Video
“Can You Answer These EPAM Java Spring Boot Questions? | 3 Yrs Mock Interview”
This video features a mock interview session with Hmon, a senior Java developer with 3.5 years of experience in Java Spring Boot and microservices. The interviewer, Ali, asks a series of technical questions commonly encountered in Java Spring Boot interviews, focusing on practical problem-solving, core Java concepts, Spring Boot internals, microservices communication, and related technologies.
Main Ideas, Concepts, and Lessons Conveyed
1. Introduction and Candidate Background
- Hmon has 3.5 years of relevant experience in Java Spring Boot and microservices.
- Currently working on an e-commerce application using microservices, Kafka, React, and MySQL.
2. Debugging and Error Handling in Spring Boot
- 500 Internal Server Error:
- Use breakpoints and debug mode to trace errors (e.g., NullPointerException).
- Check logs (logback XML) for error details.
- Scheduled Jobs Running Twice:
- Could be due to multiple instances running the same job.
- Duplicate cron jobs or misconfigured schedulers.
- Entity Updates Not Reflecting in DB:
- Possible session closure or mismatch between entity fields and DB columns.
3. Performance Optimization
- Slow endpoints querying multiple tables:
- Avoid
SELECT *, fetch only required columns. - Use pagination to limit data fetched at once.
- Avoid
4. Interview Preparation Kit
- Four parts:
- Complete interview material covering 99% of questions.
- Real enterprise client projects (code + video).
- Lifetime chat support for doubts.
- Referral support to top agencies.
5. Microservices and DTO Sharing
- Use a multi-module project to share common DTOs across microservices by placing DTOs in a common package/module.
6. Java 8 Optional Usage
- Used to avoid NullPointerException when fetching entities by ID.
- Difference between
Optional.of()(throws NPE if null) andOptional.ofNullable()(creates empty optional if null).
7. Java Concepts
- Comparator vs Comparable:
- Comparable: single natural ordering, modifies the class itself.
- Comparator: multiple custom orderings, external to the class.
- Making a Class Immutable:
- Mark class as
final. - Make fields
private final. - Remove setters.
- Use defensive copying for mutable fields like lists.
- Mark class as
- Garbage Collection:
- Works on mark-and-sweep algorithm.
- Uses young and old generation heap spaces.
- Stop-the-world event pauses app during GC.
- String Comparison:
- Use
.equals()for content equality, not==which compares references.
- Use
- Thread Safety:
- Use
Thread,Runnable,Callable. - Prefer
ConcurrentHashMapoverCollections.synchronizedMapdue to finer-grained locking (bucket-wise vs whole map).
- Use
8. Functional Interface and Stream API
- Functional Interface: single abstract method interface, annotated with
@FunctionalInterface. - Stream API improves readability and performance by enabling functional-style operations like
map,filter, and allows chaining with lambda expressions.
9. Spring Boot Internals
- Application startup begins with
SpringApplication.run(). - Uses annotations:
@SpringBootApplication(includes@EnableAutoConfiguration,@ComponentScan). - IOC container scans components and creates beans.
- Component scan can be customized to scan specific packages.
10. Dependency Injection
- Field injection vs Constructor injection:
- Constructor injection preferred for compile-time safety and no need for
@Autowiredin Spring 4+. - Field injection can lead to null pointer exceptions if dependencies are not injected properly.
- Constructor injection preferred for compile-time safety and no need for
11. Configuration Properties
@Valueinjects individual property values.@ConfigurationPropertiesbinds a group of properties into a POJO.
12. Global Exception Handling
- Use
@RestControllerAdvicefor centralized exception handling. - Use
try-catchin service layer for specific exception handling.
13. Validation Annotations
@Validand@Validatedare used for request object validation (exact differences not fully clarified).
14. JSON Conversion in Spring Boot
- Uses Jackson API internally to convert JSON to Java objects and vice versa.
- Jackson dependency is included by default in Spring Boot.
15. Performance Tuning Techniques
- Remove unnecessary dependencies.
- Optimize queries (select only required fields, avoid unnecessary joins).
- Use pagination.
- Use lazy initialization (
@Lazy) to defer bean loading until needed.
16. Custom Queries in Hibernate
- Use
@Queryannotation for HQL or native SQL queries. - HQL uses entity class names; native queries use DB table/column names.
17. Entity Behavior
- If
@Tableannotation is missing, entity class name is used as table name in lowercase. - Difference between
save(),saveAll(), andflush()methods in Spring Data JPA explained.
18. Fetch Types in JPA
FetchType.LAZY: loads related entities on demand (using proxies).FetchType.EAGER: loads related entities immediately.
19. Cascade Types
CascadeType.ALL: all operations (save, update, delete) cascade to child entities.CascadeType.MERGE: cascades only merge operations.
20. Microservices Communication
- Four ways:
RestTemplate(deprecated),RestClient,WebClient, andFeignClient. - Synchronous communication waits for response; asynchronous does not.
21. CI/CD Pipelines
- Continuous Integration and Deployment using Jenkins, Maven, Docker, Kubernetes.
- Pipeline triggers on GitHub code changes, compiles code, runs tests, packages JAR, deploys to Kubernetes cluster.
22. Git Commands
- Basic commands:
git init,git add,git status,git commit. git cherry-pickused to selectively merge commits from one branch to another.
23. Less Frequently Used Spring Boot Annotations
- Examples:
@Async,@Cacheable,@CacheEvict, stereotype annotations like@ControllerAdvice,@Service,@Repository.
Detailed Methodologies / Instructions Presented
Debugging 500 Internal Server Error
- Identify endpoint causing error.
- Set breakpoints and debug in IDE.
- Check logs (
logback.xml).
Optimizing Slow Endpoints
- Avoid
SELECT *. - Fetch only required columns.
- Use pagination to limit data size.
Making a Class Immutable
- Mark class as
final. - Make fields
private final. - Remove setter methods.
- Defensive copy mutable fields (e.g., lists).
Sharing DTOs in Microservices
- Use a multi-module project.
- Place common DTOs in a shared module/package.
Global Exception Handling in Spring Boot
- Create a class annotated with
@RestControllerAdvice. - Define exception handler methods annotated with
@ExceptionHandler.
Writing Custom Queries in Hibernate
- Use
@Queryannotation for HQL queries. - Use
nativeQuery=truefor native SQL queries.
CI/CD Pipeline Workflow
- Trigger pipeline on Git commit.
- Jenkins fetches latest code.
- Maven compiles and runs tests.
- Package code into JAR.
- Deploy Docker image to Kubernetes cluster.
Using Git Cherry-Pick
- Selectively merge specific commits from feature branch into main branch without merging all commits.
Speakers / Sources Featured
- Hmon: Senior Java Developer (candidate) with 3.5 years experience in Java Spring Boot and microservices.
- Ali: Interviewer conducting the mock interview and explaining the interview preparation kit.
This summary captures the key technical topics, practical advice, and methodologies discussed in the mock interview, providing a comprehensive overview of the candidate’s responses and the interviewer’s guidance.
Category
Educational