Video summary
Real Cognizant Java Interview Experience For 2.2 Year Developers
Main summary
Key takeaways
Summary
The video reviews a Cognizant Java interview shared by Shreya Banerjee, who had approximately 2.2 years of experience. The interviewer asked about Core Java, Spring Boot, SQL, microservices, security, concurrency, and practical backend design. The presenter emphasizes explaining concepts clearly and supporting experience-based answers with concrete examples.
Core Java
HashMapinternals: AHashMapstores key–value pairs in buckets. It uses a key’shashCode()to locate a bucket andequals()to identify the exact key, especially when keys collide. Under heavy collisions, a bucket may be converted from a linked list to a tree.hashCode()andequals(): Both methods matter in hash-based collections and must be implemented consistently. Incorrect implementations can cause failed lookups or unexpected duplicates.hashCode()helps locate a bucket;equals()checks whether keys match.ArrayListvs.LinkedList: AnArrayListuses a dynamic array and is generally faster for indexed access. ALinkedListuses nodes and can insert or remove efficiently once the relevant position is reached, though finding that position may take time. The presenter saysArrayListis preferred in most cases.finallyblocks: Afinallyblock normally runs, but may not execute if the JVM or process terminates abruptly, such as throughSystem.exitor a fatal crash.- Interfaces and constructors: Interfaces cannot have constructors because they cannot be instantiated directly.
- Constructor rules: Constructors have no declared return type and cannot be
finalorstatic. Object creation produces the object; the constructor itself does not declare a return value. - “Is-a” and “has-a”: “Is-a” describes inheritance (for example, a dog is an animal), while “has-a” describes composition (for example, a car has an engine). The presenter recommends composition for flexibility.
- Encapsulation: Keep fields private and provide getters or setters as appropriate to allow controlled access and validation.
- Functional interfaces: A functional interface has one abstract method and can be used with lambda expressions. Examples mentioned include
Runnable,Callable,Comparator,Predicate, andFunction.
The presenter says Comparable is not treated as a functional interface because it was designed for natural ordering rather than flexible lambda use. More precisely, it has one abstract method and can technically be used as a functional interface, although it is not annotated with @FunctionalInterface. Comparator is often more flexible.
Spring Boot and Application Development
- Common annotations: Examples include
@SpringBootApplication,@Controller,@Service,@Repository,@Autowired,@RequestMapping, and@PathVariable. @Valuevs.@ConfigurationProperties:@Valueis suitable for injecting an individual property.@ConfigurationPropertiesmaps groups of related properties into a class and is preferable for structured configuration.- Default logging: The presenter identifies SLF4J as the logging API and Logback as Spring Boot’s default implementation.
- Field injection: Field injection places
@Autowireddirectly on a field. Its drawbacks include hidden dependencies, harder testing, and limited support for immutability. Constructor injection is presented as preferable. - Bean lifecycle:
@PostConstructruns after bean creation and dependency injection, making it useful for initialization.@PreDestroyruns before bean destruction and can be used for cleanup. - Caching: Caching stores results to make repeated requests faster. Spring’s
@Cacheablecan cache method results, while@CacheEvictremoves cached entries. Redis and in-memory caching are possible implementations. - Custom Spring Boot starter: A starter can bundle dependencies and configuration. The presenter describes creating auto-configuration with conditional annotations and exposing the relevant metadata so other projects can use it.
- Maven
.m2folder: This folder stores dependencies locally so Maven can reuse them instead of downloading them repeatedly. It can also contain Maven settings such assettings.xml.
SQL and Performance
- Indexes: An index speeds up data lookup by avoiding a full-table scan, but too many indexes can slow down inserts and other updates.
- Query optimization: Identify slow queries using logs, inspect execution plans and indexes, then improve joins and reduce the amount of data processed.
Microservices and System Design
- Service communication: REST is presented as a synchronous communication option, while Kafka supports asynchronous, event-driven communication. The choice depends on the use case.
- Distributed transactions: If a booking succeeds but payment fails, a direct rollback across services may not be available. The presenter recommends the Saga pattern, which uses a compensating action—such as canceling the booking—to restore consistency.
- Concurrent requests: The presenter mentions synchronization or locks, stateless services, and scaling. Systems should be designed carefully to handle concurrent users and load.
- High traffic for the same request: Suggested measures include using a load balancer, caching repeated results, applying asynchronous processing where appropriate, and scaling services.
- Circuit breaker half-open state: The three states are closed, open, and half-open. In the half-open state, a limited number of requests test whether a failing service has recovered. Success returns the breaker to closed; failure returns it to open.
Security
- JWT authentication: The client sends a token with each request, and the server validates it. This supports stateless authentication without requiring a server-side session.
- OAuth 2.0: The video distinguishes authorization from authentication. A client obtains an access token through an authorization server and uses it to access an API, without sharing the user’s password with that API.
- Microservice authentication and authorization: Authentication can use JWT or OAuth 2.0. Services validate tokens and check roles or permissions. The presenter recommends a central authentication service.
Coding and Interview Preparation
- Sum digits using streams: Convert the number to a string, stream its characters, convert each character to a digit, and sum the digits, potentially using
reduce. - Sum digits without streams: Use a loop to repeatedly extract the last digit with
% 10, add it to a running total, and divide the number by 10. - Discuss Java versions and project work: Name the Java version used and describe features applied in practice—for example, records, switch expressions, or stream improvements—rather than only naming a version.
- Describe recent project work: Give concrete examples, such as API development, performance optimization, or microservices work, and explain the challenges and solutions.
Speakers and Sources
- Presenter: The unnamed host of the JAVA INTERVIEW BUDDY channel, who presents and explains the interview questions.
- Interview source: Shreya Banerjee (pronounced “Banerji” in the subtitles), who shared questions from her Cognizant interview and had approximately 2.2 years of experience.
Rate this summary
Your feedback will help improve summaries.
Improve this summary
Reprocess with a stronger model when the summary feels incomplete or inaccurate.
Translate summary in another language
Ask questions to this video
Chat for follow-up questions, clarifications, and source-backed answers.