Skip to main content

Infosys Java Interview | 4 to 7 Years | Java | Microservices | Database | Spring Boot

 Infosys Java Interview | 4 to 7 Years | Java | Microservices | Database | Spring Boot





📺 This post is based on a real mock interview discussion. All answers are paraphrased and structured for learning purposes.
🔗 Video credit: CloudTech Watch here


Q1: Can you tell me about your project architecture?

Answer:
The project transitioned from monolithic to microservices architecture. It uses Zuul as the API Gateway, and Consul (previously Eureka) for service discovery. Each microservice registers itself with the discovery server. The architecture supports client-side load balancing and uses both relational (e.g., MySQL) and NoSQL (MongoDB) databases.


Q2: How do microservices communicate with each other?

Answer:

  • Synchronous communication: Uses FeignClient (earlier RestTemplate).

  • Asynchronous communication: Uses Kafka. Events are published and consumed across services without waiting for a reply.


Q3: What features are implemented in the API Gateway?

Answer:

  • Authentication and Authorization

  • Rate Limiting (returns HTTP 429 on too many requests)

  • Response Aggregation from multiple services


Q4: What design patterns and SOLID principles do you follow?

Answer:

  • Design Patterns: Singleton, Strategy, Builder

  • SOLID Principles:

    • S: Single Responsibility

    • O: Open/Closed Principle

    • L: Liskov Substitution

    • I: Interface Segregation

    • D: Dependency Inversion (handled via Spring's Dependency Injection)


Q5: How do you structure a Spring Boot CRUD application?

Answer:

  • Layers: Controller → Service → Repository

  • Annotations: @RestController, @Service, @Repository

  • HTTP Methods: GET, POST, PUT, DELETE

  • Status Codes: 200 (OK), 201 (Created), 401 (Unauthorized), 403 (Forbidden), 404 (Not Found)


Q6: What is your packaging structure?

Answer:
Uses base package like com.cloudtech.projectname with sub-packages for controller, service, repository, and separate folders for resources and test cases.


Q7: How do you connect your Spring Boot app with a database?

Answer:
Using application.properties to define database url, username, and password. Spring Boot auto-configures the datasource.


Q8: How do you optimize a slow-performing API?

Answer:

  • Check network latency

  • Analyze SQL query logic

  • Ensure proper indexing on filter/join columns


Q9: What is the purpose of indexing in databases?

Answer:
Indexes speed up queries by avoiding full table scans. Instead of scanning each row, the database uses the index to directly fetch relevant rows.


Q10: What types of joins exist in SQL?

Answer:

  • Inner Join: Returns matching rows from both tables.

  • Left Outer Join: Returns all rows from the left table, and matched rows from the right.

  • Right Outer Join: Returns all rows from the right table, and matched rows from the left.

  • Full Outer Join: Returns all rows from both tables, matched or not.


Q11: Which Java version do you use and what are Java 8 features?

Answer:
Using Java 11 with Java 8 features like:

  • Functional Interfaces

  • Lambda Expressions

  • Streams API

  • Date/Time API

  • StringJoiner


Q12: How to filter employees aged over 60 using Streams?

Answer:

List<Employee> seniorEmployees = employees.stream()
    .filter(e -> e.getAge() > 60)
    .collect(Collectors.toList());

Q13: How do you handle exceptions in Java?

Answer:
Use try-catch blocks or throws keyword. For cleanup, use finally block.


Q14: Types of Exceptions?

Answer:

  • Checked Exceptions: Must be handled at compile time (e.g., IOException).

  • Unchecked Exceptions: Runtime issues like NullPointerException, IndexOutOfBoundsException.


Q15: When is finally block not executed?

Answer:

  • When JVM shuts down via System.exit()

  • When fatal errors like OutOfMemoryError occur


Q16: What is a deadlock and how to avoid it?

Answer:

  • Deadlock: Two threads wait indefinitely for resources held by each other.

  • Prevention: Avoid nested locking or use timeout mechanisms.


Q17: What are wait() and notify() in Java?

Answer:
Used for inter-thread communication, like in producer-consumer problems. wait() releases lock and pauses thread, notify() wakes a waiting thread.


Q18: Difference between HashMap and ConcurrentHashMap?

Answer:

  • HashMap: Not thread-safe, suitable for single-threaded apps.

  • ConcurrentHashMap: Thread-safe using segmented locks, ideal for concurrent apps.


Q19: Difference between ArrayList and LinkedList?

Answer:

  • ArrayList: Fast for random access, backed by array.

  • LinkedList: Fast for insert/delete, backed by nodes with references.


Q20: Difference between SQL and NoSQL databases?

Answer:

  • SQL: Structured schema, uses SQL for queries (e.g., MySQL).

  • NoSQL: Schema-less, good for flexible data formats (e.g., MongoDB)


💡 Conclusion
This mock interview covers real-world Java backend development scenarios including Spring Boot, microservices, exception handling, and Java 8 features. Ideal for preparing INFOSYS and other enterprise-level backend developer roles.

📺 Inspired by CloudTech’s interview video. Watch here: https://www.youtube.com/watch?v=TNEfRtkla_0

👍 Drop a comment if you’d like more breakdowns like this or want to practice your own interview answers!

Comments

Popular posts from this blog

TCS Java Interview | Java | Spring Boot | Microservices | Database

TCS Java Interview | Java | Spring Boot | Microservices | Database This post is based on a Java backend developer interview simulation and provides direct transcript-based answers to help you prepare for similar interviews. 📺 This interview scenario was inspired by a video from the  YouTube channel:  CloudTech . 🔗 Watch the full video here:  https://www.youtube.com/watch?v=yVj2EgwZxk4 1. Can you introduce yourself and talk about your tech stack and domains? I have around 4.5 years of experience working as a Java developer. My core expertise is in Java and developing REST APIs using Spring Boot. I also have basic knowledge of microservices architecture. On the database side, I work with SQL and Oracle. Additionally, I have exposure to UI technologies like Angular, HTML, and CSS, but they are secondary skills. My primary focus is backend Java development. 2. Which version of Java are you currently working on? We are currently using Java 8 but are in the process of upgr...

Top 20 Spring Boot Microservices Architecture Interview Questions (With Speakable Answers)

Top 20 Spring Boot Microservices Architecture Interview Questions (With Speakable Answers) * * * 1. What is Microservices Architecture?   → Microservices architecture breaks an application into small, independent services. Each one handles a specific business function and can be developed, deployed, and scaled independently. They usually communicate over REST APIs or messaging queues. * * * 2. How does Spring Boot help in building microservices?   → Spring Boot offers embedded servers, auto-configuration, starter templates, and production-ready tools. It works well with Spring Cloud to provide service discovery, config management, load balancing, and more. * * * 3. What are the core components in a microservices setup?   → Key components include:   ✓ API Gateway   ✓ Eureka (Service Discovery)   ✓ Config Server   ✓ Kafka or RabbitMQ   ✓ Circuit Breaker (like Resilience4j)   ✓ Centralized logging and monitoring (ELK, Prometheus) * * * 4. What i...

Top 15 React Interview Questions for 1–2 Years Experience

🟦 Top 15 React Interview Questions for 1–2 Years Experience Preparing for a React interview with 1–2 years of experience? Here's a carefully curated list of 15 important React questions with clear, real-world answers. These are frequently asked in interviews at companies like TCS, Infosys, Cognizant, Capgemini, and product-based firms. Q1. What is the Virtual DOM in React, and how does it improve performance? Answer: The Virtual DOM is a lightweight, in-memory copy of the real DOM. When state/props change, React creates a new Virtual DOM tree, compares it with the old one (diffing), and only updates the parts of the real DOM that changed. This makes rendering much faster and improves performance in large applications. Q2. What is JSX in React? Answer: JSX stands for JavaScript XML. It allows us to write HTML elements in JavaScript and place them in the DOM without using createElement() . JSX improves code readability and is transpiled to React.createElement() calls. ...