TCS

TCS Interview Questions

Core Java fundamentals, Spring Boot basics, and SQL are the focus. Docker and Kubernetes knowledge is increasingly expected for DevOps roles.

278questions
76 Easy202 Medium

#1What is the difference between == and .equals() in Java?

Easy
Core JavaJava

#2What is the difference between abstract class and interface?

Easy
OOPJava

#3Explain the SOLID principles.

Medium
OOPJava

#4How does HashMap work internally?

Medium
CollectionsJava

#5What is the difference between HashMap and ConcurrentHashMap?

Medium
CollectionsJava

#6Explain Java Memory Model: Heap, Stack, and Metaspace.

Medium
JVMJava

#7What is the volatile keyword in Java?

Medium
ConcurrencyJava

#8What are functional interfaces and lambda expressions in Java 8?

Easy
Java 8+Java

#9What is Optional and when should you use it?

Easy
Java 8+Java

#10Explain the Stream API and intermediate vs terminal operations.

Medium
Java 8+Java

#11What is the difference between checked and unchecked exceptions?

Easy
Core JavaJava

#12What is the difference between String, StringBuilder, and StringBuffer?

Easy
Core JavaJava

#13What is method overloading vs method overriding?

Easy
OOPJava

#14What is the difference between final, finally, and finalize?

Easy
Core JavaJava

#15What are Java records (Java 16+)?

Medium
Java 8+Java

#16What is the Executor framework and when would you use it over raw Threads?

Medium
ConcurrencyJava

#17What is encapsulation and how is it achieved in Java?

Easy
OOPJava

#18What is polymorphism? Explain runtime vs compile-time polymorphism.

Easy
OOPJava

#19What is the difference between composition and inheritance?

Medium
OOPJava

#20What is a marker interface? Give examples.

Medium
OOPJava

#21What are the design patterns most commonly asked in Java interviews?

Medium
OOPJava

#22What is the difference between ArrayList and LinkedList?

Easy
CollectionsJava

#23What is the difference between HashSet, LinkedHashSet, and TreeSet?

Easy
CollectionsJava

#24What is the difference between HashMap and TreeMap?

Easy
CollectionsJava

#25What is the contract between equals() and hashCode()?

Medium
CollectionsJava

#26What is the difference between fail-fast and fail-safe iterators?

Medium
CollectionsJava

#27What is CopyOnWriteArrayList and when should you use it?

Medium
CollectionsJava

#28How does PriorityQueue work and when would you use it?

Medium
CollectionsJava

#29What is the difference between sleep(), wait(), and yield()?

Medium
ConcurrencyJava

#30What are atomic classes (AtomicInteger, AtomicReference)? How do they work?

Medium
ConcurrencyJava

#31What is a CountDownLatch vs CyclicBarrier?

Medium
ConcurrencyJava

#32What is the difference between JDK, JRE, and JVM?

Easy
JVMJava

#33What is the String pool and how does string interning work?

Medium
JVMJava

#34What are sealed classes (Java 17)?

Medium
Java 8+Java

#35What is pattern matching for instanceof (Java 16)?

Medium
Java 8+Java

#36What are text blocks (Java 15)?

Easy
Java 8+Java

#37What is the difference between map() and flatMap() in streams?

Medium
Java 8+Java

#38What are method references in Java 8?

Easy
Java 8+Java

#39What is the difference between Comparable and Comparator?

Medium
CollectionsJava

#40What is Stream.collect() and what are common Collectors?

Medium
Java 8+Java

#41What is try-with-resources and how does it work?

Medium
Exception HandlingJava

#42What is the difference between throw and throws?

Easy
Exception HandlingJava

#43What is exception chaining and why is it important?

Medium
Exception HandlingJava

#44What is the difference between Java IO and NIO?

Medium
Core JavaJava

#45What is reflection in Java and when is it used?

Medium
Core JavaJava

#46What is the difference between deep copy and shallow copy?

Medium
Core JavaJava

#47What is autoboxing and unboxing? What are the performance implications?

Medium
Core JavaJava

#48What are enums in Java and what advanced features do they support?

Medium
Core JavaJava

#49What is the difference between static and instance initializer blocks?

Medium
Core JavaJava

#50What is the difference between String.format() and String.formatted()?

Easy
Core JavaJava

#51What is the var keyword (Java 10) and when should you use it?

Easy
Java 8+Java

#52What is the difference between an inner class, static nested class, and anonymous class?

Medium
OOPJava

#53What are the new switch expressions (Java 14)?

Medium
Java 8+Java

#54What is the difference between Runnable, Callable, and Future?

Medium
ConcurrencyJava

#55What is the difference between String.equals() and String.equalsIgnoreCase()?

Easy
Core JavaJava

#56What is the difference between Iterator and ListIterator?

Easy
CollectionsJava

#57What is the difference between abstract class and concrete class?

Easy
OOPJava

#58How do you handle NullPointerException in Java?

Medium
Exception HandlingJava

#59What is the Collections utility class? What are its most important methods?

Easy
CollectionsJava

#60What is the difference between Deque and Queue?

Medium
CollectionsJava

#61What is the difference between checked and unchecked exceptions — best practices for APIs?

Medium
Exception HandlingJava

#62What is the ternary operator and the null-coalescing equivalent in Java?

Easy
Core JavaJava

#63What is the difference between == null check and Objects.isNull()?

Easy
Core JavaJava

#64What is the difference between interface default methods and abstract class methods?

Medium
OOPJava

#65What is the difference between Iterable and Iterator?

Easy
CollectionsJava

#66What are the best practices for writing clean Java code?

Medium
Core JavaJava

#67What is the difference between a process and a thread in Java?

Easy
ConcurrencyJava

#68What is a race condition and how do you prevent it?

Medium
ConcurrencyJava

#69What is the difference between HashMap.computeIfAbsent() and getOrDefault()?

Medium
CollectionsJava

#70What is the purpose of the transient keyword?

Medium
Core JavaJava

#71What is the difference between i++ and ++i in Java?

Easy
Core JavaJava

#72What are the Java 8 Date/Time APIs and why were they introduced?

Medium
Java 8+Java

#73What is the difference between HashMap.put() and HashMap.putIfAbsent()?

Medium
CollectionsJava

#74What is the difference between String.valueOf() and toString()?

Easy
Core JavaJava

#75What is an immutable class and how do you create one?

Medium
OOPJava

#76What is the covariant return type in Java?

Medium
OOPJava

#77What is the difference between static and instance methods?

Easy
OOPJava

#78What is the difference between Predicate.and(), Predicate.or(), and Predicate.negate()?

Medium
Java 8+Java

#79What is the Observer pattern and how is it implemented in Java?

Medium
OOPJava

#80What is the Strategy pattern in Java?

Medium
OOPJava

#81What are the key differences between Java 8, 11, 17, and 21?

Medium
Java 8+Java

#82What is auto-configuration in Spring Boot?

Medium
Core ConceptsSpring Boot

#83What is @SpringBootApplication and what does it do?

Easy
Core ConceptsSpring Boot

#84What is IoC (Inversion of Control) and Dependency Injection?

Easy
Core ConceptsSpring Boot

#85What is the difference between @Component, @Service, and @Repository?

Easy
Core ConceptsSpring Boot

#86What is the difference between @Controller and @RestController?

Easy
REST APISpring Boot

#87How does Spring Boot handle exceptions globally?

Medium
REST APISpring Boot

#88What is Spring Boot Actuator?

Easy
ProductionSpring Boot

#89What is the difference between @Bean and @Component?

Medium
Core ConceptsSpring Boot

#90Explain Spring Bean scopes.

Medium
Core ConceptsSpring Boot

#91How do you configure Spring profiles?

Easy
ConfigurationSpring Boot

#92What is @Async in Spring Boot and how does it work?

Medium
AdvancedSpring Boot

#93What is Spring Data JPA and how does it simplify data access?

Medium
Data AccessSpring Boot

#94How does Spring Boot externalized configuration work?

Medium
ConfigurationSpring Boot

#95What is Spring Cache Abstraction and how do you use it?

Medium
AdvancedSpring Boot

#96What are Spring Boot starters and why are they useful?

Easy
Core ConceptsSpring Boot

#97How do you write integration tests in Spring Boot?

Medium
TestingSpring Boot

#98What is the Spring ApplicationContext and how does it differ from BeanFactory?

Medium
Core ConceptsSpring Boot

#99What is the @PostConstruct and @PreDestroy lifecycle?

Medium
Core ConceptsSpring Boot

#100What is @Qualifier and when do you need it?

Medium
Core ConceptsSpring Boot

#101What is @ConfigurationProperties and how does it differ from @Value?

Medium
ConfigurationSpring Boot

#102What is Spring Boot's embedded server and how do you switch from Tomcat to Undertow?

Medium
Core ConceptsSpring Boot

#103What is Spring's @EventListener and ApplicationEvent?

Medium
AdvancedSpring Boot

#104What is Spring Boot DevTools?

Easy
Core ConceptsSpring Boot

#105What is the difference between @RequestParam, @PathVariable, and @RequestBody?

Easy
REST APISpring Boot

#106How do you implement request validation in Spring Boot?

Medium
REST APISpring Boot

#107What is ResponseEntity and when should you use it?

Medium
REST APISpring Boot

#108What is content negotiation in Spring MVC?

Medium
REST APISpring Boot

#109How do you implement pagination and sorting in Spring Boot?

Medium
REST APISpring Boot

#110How do you version a REST API in Spring Boot?

Medium
REST APISpring Boot

#111What is the difference between findById() and getById() in Spring Data JPA?

Medium
Data AccessSpring Boot

#112What is the difference between @OneToMany with fetch LAZY vs EAGER?

Medium
Data AccessSpring Boot

#113What is CSRF and how does Spring Security handle it?

Medium
SecuritySpring Boot

#114What is the difference between @Secured, @PreAuthorize, and @RolesAllowed?

Medium
SecuritySpring Boot

#115What is CORS and how do you configure it in Spring Boot?

Medium
SecuritySpring Boot

#116What is MockMvc and how do you use it?

Medium
TestingSpring Boot

#117What is @MockBean vs @Mock in Spring Boot tests?

Medium
TestingSpring Boot

#118What is @DataJpaTest and how does it differ from @SpringBootTest?

Medium
TestingSpring Boot

#119What is Testcontainers and how does it improve Spring Boot tests?

Medium
TestingSpring Boot

#120What is Micrometer and how does it integrate with Spring Boot Actuator?

Medium
ProductionSpring Boot

#121How do you implement custom health indicators in Spring Boot?

Medium
ProductionSpring Boot

#122What is graceful shutdown in Spring Boot and how do you configure it?

Medium
ProductionSpring Boot

#123What is @ControllerAdvice and how does it work?

Medium
REST APISpring Boot

#124What is Spring's @Scheduled and how do you configure it?

Medium
AdvancedSpring Boot

#125What is CommandLineRunner and ApplicationRunner?

Easy
Core ConceptsSpring Boot

#126What is Spring Boot's banner and how can you customize it?

Easy
Core ConceptsSpring Boot

#127What is Spring Retry and how do you use it?

Medium
AdvancedSpring Boot

#128What is @Transactional readOnly = true and what does it optimize?

Medium
Data AccessSpring Boot

#129How do you handle file uploads in Spring Boot?

Medium
REST APISpring Boot

#130What is the difference between @RequestMapping and specific mapping annotations?

Easy
REST APISpring Boot

#131What is the difference between @Transactional on a class vs a method?

Medium
Data AccessSpring Boot

#132What is Spring Boot's connection pool? How do you tune HikariCP?

Medium
Data AccessSpring Boot

#133What is Spring Boot's auto-configuration for messaging (RabbitMQ / Kafka)?

Medium
AdvancedSpring Boot

#134How does Spring Boot handle environment-specific properties?

Medium
ConfigurationSpring Boot

#135What is the purpose of @EnableJpaAuditing?

Medium
Data AccessSpring Boot

#136What is the difference between eager and lazy initialization in Spring Boot?

Medium
Core ConceptsSpring Boot

#137What is Spring Boot's support for caching with Redis?

Medium
AdvancedSpring Boot

#138What is Spring Boot's support for MongoDB?

Medium
Data AccessSpring Boot

#139What is the difference between @Valid and @Validated in Spring?

Medium
REST APISpring Boot

#140What is Spring Data REST and how does it differ from Spring MVC?

Medium
Data AccessSpring Boot

#141What is the difference between @Inject and @Autowired?

Easy
Core ConceptsSpring Boot

#142What is Flyway and how does it integrate with Spring Boot?

Medium
Data AccessSpring Boot

#143What are Spring Boot's management endpoints and how do you secure them?

Medium
ProductionSpring Boot

#144What is Spring Boot's Docker image building support?

Medium
ProductionSpring Boot

#145What is the difference between @SpringBootTest(webEnvironment) options?

Medium
TestingSpring Boot

#146What is Spring Boot's support for SSE (Server-Sent Events)?

Medium
AdvancedSpring Boot

#147What are the different types of SQL JOINs?

Easy
QueryingMySQL

#148How does indexing work in MySQL (InnoDB)?

Medium
IndexingMySQL

#149What is a covering index?

Medium
IndexingMySQL

#150How do you use EXPLAIN to analyze a query?

Medium
PerformanceMySQL

#151What are CTEs (Common Table Expressions) and when should you use them?

Medium
Advanced SQLMySQL

#152What is the N+1 query problem and how do you fix it?

Medium
PerformanceMySQL

#153What is a deadlock in MySQL and how does it occur?

Medium
TransactionsMySQL

#154What is the difference between DELETE, TRUNCATE, and DROP?

Easy
QueryingMySQL

#155What is database normalization?

Medium
Schema DesignMySQL

#156What is GROUP BY vs HAVING in SQL?

Easy
QueryingMySQL

#157What is a stored procedure and when should you use it?

Medium
Advanced SQLMySQL

#158What is the difference between UNION and UNION ALL?

Easy
QueryingMySQL

#159What is the difference between a clustered and a non-clustered index?

Medium
IndexingMySQL

#160How does MySQL handle AUTO_INCREMENT?

Easy
Schema DesignMySQL

#161What are covering indexes and how do they improve performance?

Medium
IndexingMySQL

#162What is the EXPLAIN output and how do you read it?

Medium
PerformanceMySQL

#163What are database triggers and when should you avoid them?

Medium
Schema DesignMySQL

#164What is a foreign key constraint and what are its performance implications?

Medium
Schema DesignMySQL

#165What is the difference between CHAR and VARCHAR?

Easy
Schema DesignMySQL

#166How do you implement full-text search in MySQL?

Medium
QueryingMySQL

#167What is the difference between MyISAM and InnoDB?

Easy
FundamentalsMySQL

#168What are MySQL stored procedures and when should you use them?

Medium
FundamentalsMySQL

#169How do you perform a slow query analysis in MySQL?

Medium
PerformanceMySQL

#170What is the difference between HAVING and WHERE?

Easy
QueryingMySQL

#171What is MySQL's query cache and why was it removed?

Medium
PerformanceMySQL

#172How do you back up a MySQL database without downtime?

Medium
OperationsMySQL

#173What is the difference between optimistic and pessimistic locking in MySQL?

Medium
TransactionsMySQL

#174What is the difference between IN, EXISTS, and JOIN for subqueries?

Medium
QueryingMySQL

#175How do you implement pagination in MySQL efficiently?

Medium
PerformanceMySQL

#176What are the different types of JOINs in MySQL?

Easy
QueryingMySQL

#177What is the difference between a view and a materialized view?

Medium
Schema DesignMySQL

#178What are common MySQL performance anti-patterns?

Medium
PerformanceMySQL

#179What is a generated column in MySQL?

Medium
Schema DesignMySQL

#180What are the best practices for MySQL schema design?

Medium
Schema DesignMySQL

#181How do you use MySQL's JSON column type?

Medium
Schema DesignMySQL

#182What is ProxySQL and how is it used?

Medium
OperationsMySQL

#183How do you detect and fix index fragmentation in MySQL?

Medium
PerformanceMySQL

#184What are the MySQL 8.0 improvements over MySQL 5.7?

Medium
FundamentalsMySQL

#185How do you design a schema for audit logging?

Medium
Schema DesignMySQL

#186What is the difference between COUNT(*), COUNT(1), and COUNT(col)?

Easy
QueryingMySQL

#187How do you implement soft delete in MySQL?

Medium
Schema DesignMySQL

#188What is the difference between CHAR, VARCHAR, TEXT, and BLOB?

Easy
Schema DesignMySQL

#189What is the difference between schema-on-write and schema-on-read?

Medium
FundamentalsMySQL

#190How do you handle time zones in MySQL?

Medium
OperationsMySQL

#191What is the difference between a unique constraint and a unique index?

Easy
IndexingMySQL

#192How do you monitor MySQL in production?

Medium
OperationsMySQL

#193What are window functions and how do you use them?

Medium
QueryingMySQL

#194What is the difference between a primary key and a unique key?

Easy
IndexingMySQL

#195How do you use MySQL's event scheduler?

Medium
OperationsMySQL

#196What is the EXPLAIN ANALYZE command?

Medium
PerformanceMySQL

#197How do you handle database connection failures in application code?

Medium
OperationsMySQL

#198What is the MySQL query execution order?

Medium
QueryingMySQL

#199How do you scale MySQL reads?

Medium
ReplicationMySQL

#200What is the difference between row-based and statement-based replication?

Medium
ReplicationMySQL

#201How do you use CTEs (Common Table Expressions) effectively?

Medium
QueryingMySQL

#202What is the difference between TRUNCATE, DELETE, and DROP?

Easy
OperationsMySQL

#203How do you implement optimistic locking with versioning in MySQL?

Medium
TransactionsMySQL

#204What are the different ways to copy a table in MySQL?

Easy
OperationsMySQL

#205What is the purpose of the information_schema?

Medium
OperationsMySQL

#206How do you implement full-table search across millions of rows efficiently?

Medium
PerformanceMySQL

#207What is the max_connections parameter and how do you tune it?

Medium
OperationsMySQL

#208What is the difference between ROLLUP and CUBE in SQL?

Medium
QueryingMySQL

#209How do you handle NULL values in MySQL queries?

Medium
QueryingMySQL

#210What is the difference between a read and a write transaction?

Medium
TransactionsMySQL

#211What is the mysql.user table and how does MySQL authentication work?

Medium
SecurityMySQL

#212What are MySQL's data types for storing money?

Medium
Schema DesignMySQL

#213What is the difference between DATETIME and TIMESTAMP in MySQL?

Easy
Schema DesignMySQL

#214What is Docker and how does it differ from a VM?

Easy
FundamentalsDocker

#215What is the difference between a Docker image and a container?

Easy
FundamentalsDocker

#216Explain the difference between CMD and ENTRYPOINT in a Dockerfile.

Medium
DockerfileDocker

#217What is a multi-stage build and why is it important?

Medium
Best PracticesDocker

#218What are Docker volumes and when would you use bind mounts instead?

Medium
StorageDocker

#219Explain Docker networking modes.

Medium
NetworkingDocker

#220How do you reduce Docker image size?

Medium
Best PracticesDocker

#221How does Docker layer caching work?

Medium
DockerfileDocker

#222What is Docker Compose and when would you use it?

Easy
ComposeDocker

#223What is a Docker health check?

Medium
OperationsDocker

#224How do you handle logging in Docker containers?

Medium
OperationsDocker

#225What is the difference between docker stop and docker kill?

Medium
OperationsDocker

#226How do you debug a running Docker container?

Medium
OperationsDocker

#227What is Docker Swarm and how does it compare to Kubernetes?

Medium
OrchestrationDocker

#228What are Docker labels and how are they used?

Easy
OperationsDocker

#229What is the .dockerignore file and why is it important?

Easy
Best PracticesDocker

#230What are Docker ARG and ENV and how do they differ?

Medium
DockerfileDocker

#231What is the difference between COPY and ADD in a Dockerfile?

Easy
DockerfileDocker

#232How do you set resource limits on Docker containers?

Medium
OperationsDocker

#233What is a Docker registry and how do you set up a private one?

Medium
OperationsDocker

#234What is WORKDIR in a Dockerfile and why should you use it?

Easy
DockerfileDocker

#235How does Docker handle container restart policies?

Easy
OperationsDocker

#236What is the principle of container immutability and how do you implement it?

Medium
Best PracticesDocker

#237How do you handle environment-specific configuration in Docker?

Medium
Best PracticesDocker

#238What is a multi-platform Docker image and how do you build one?

Medium
Best PracticesDocker

#239What is the difference between EXPOSE and port publishing in Docker?

Easy
NetworkingDocker

#240How do you troubleshoot a container that won't start?

Medium
OperationsDocker

#241How do you use Docker for local database development?

Easy
DevelopmentDocker

#242How do you use Docker exec and what are common use cases?

Easy
OperationsDocker

#243What is a Dockerfile SHELL instruction?

Medium
DockerfileDocker

#244How do you use Docker Compose for integration testing?

Medium
CI/CDDocker

#245What is Docker image tagging strategy?

Medium
Best PracticesDocker

#246What is the difference between CMD in shell form vs exec form?

Medium
DockerfileDocker

#247What is a Docker context?

Medium
OperationsDocker

#248How do you scan Docker images for vulnerabilities?

Medium
SecurityDocker

#249How do you implement service-to-service communication with Docker Compose?

Medium
ComposeDocker

#250What are Docker Compose profiles?

Easy
ComposeDocker

#251How do you monitor Docker containers?

Medium
OperationsDocker

#252How do you use Docker volumes for persistent data and backups?

Medium
StorageDocker

#253What is a distroless image and when should you use it?

Medium
SecurityDocker

#254How do you cache dependencies effectively for different languages in Docker?

Medium
Best PracticesDocker

#255What is the Docker container lifecycle?

Easy
FundamentalsDocker

#256What is COPY --chown and how do you set file permissions in Dockerfile?

Medium
SecurityDocker

#257What is Docker's garbage collection and how do you manage disk space?

Easy
OperationsDocker

#258What is Docker Desktop and how does it differ from Docker Engine?

Easy
FundamentalsDocker

#259How do you implement health-dependent startup ordering in Docker Compose?

Medium
ComposeDocker

#260How do you share data between containers in Docker?

Medium
StorageDocker

#261What is Podman and how does it compare to Docker?

Medium
FundamentalsDocker

#262How do you handle configuration management across multiple Docker environments?

Medium
Best PracticesDocker

#263What is the difference between docker commit and building from Dockerfile?

Easy
Best PracticesDocker

#264How do you configure the Docker daemon (dockerd)?

Medium
OperationsDocker

#265What is the Docker build context and how does it affect build performance?

Medium
DockerfileDocker

#266How do you use Docker with GitHub Actions for CI/CD?

Medium
CI/CDDocker

#267What is the Docker Compose watch feature and how does it improve developer experience?

Easy
DevelopmentDocker

#268What is image layer sharing and how does it save storage?

Medium
InternalsDocker

#269What is Docker Scout and how does it improve supply chain security?

Medium
SecurityDocker

#270How do you run stateful applications in Docker?

Medium
StorageDocker

#271How do you handle log rotation and disk usage for Docker container logs?

Medium
OperationsDocker

#272What are Docker's best practices for production deployments?

Medium
Best PracticesDocker

#273How do you optimize Docker for Node.js applications?

Medium
Best PracticesDocker

#274What is Docker's host network mode and when should you use it?

Medium
NetworkingDocker

#275What is an SBOM and how do you generate one for Docker images?

Medium
SecurityDocker

#276What is a multi-container application pattern vs microservices in Docker?

Medium
ArchitectureDocker

#277How do you implement service health checks and readiness probes in production?

Medium
OperationsDocker

#278What are the limits of Docker and when should you move to Kubernetes?

Medium
ArchitectureDocker