0% found this document useful (0 votes)
7 views3 pages

Java Developer Interview Questions Guide

Uploaded by

poonam.upadhye28
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Java Developer Interview Questions Guide

Uploaded by

poonam.upadhye28
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

💡 Java Developer Interview Experience @TCS 🚀

1️⃣ Difference between JDK, JRE, and JVM?


2️⃣ How does Java achieve platform independence?
3️⃣ What are checked and unchecked exceptions? Give examples.
4️⃣ Difference between String, StringBuilder, and StringBuffer?
5️⃣ What is the difference between final, finally, and finalize()?
6️⃣ Explain the concept of Garbage Collection in Java.
7️⃣ What is the difference between ArrayList and LinkedList?
8️⃣ What is ConcurrentHashMap and how is it different from HashMap?
9️⃣ Explain thread lifecycle in Java.
🔟 How do you create a thread in Java? Difference between extending Thread and
implementing Runnable?
1️⃣1️⃣ What is the use of the volatile keyword in Java multithreading?
1️⃣2️⃣ Explain the difference between REST and SOAP web services.
1️⃣3️⃣ How does Spring Dependency Injection work?
1️⃣4️⃣ What are Spring Boot starters?
1️⃣5️⃣ Explain @Component, @Service, @Repository annotations in Spring.
1️⃣6️⃣ How do you handle transactions in Spring Boot?
1️⃣7️⃣ Explain CI/CD pipeline – how did you implement it in your project?
1️⃣8️⃣ What is Kubernetes and how is it different from Docker?
1️⃣9️⃣ How do you secure REST APIs in Spring Boot?
2️⃣0️⃣ What are the SOLID principles in Java?

Round -1
Introduce yourself and explain your project.
Difference between IOC and Dependency Injection
What is Dependency Injection and its types?
How does the @Transactional annotation work?
What is Fetch Type (Lazy vs Eager Loading)?
Explain and implement the Factory Design Pattern (with some modifications).
What is JWT security, and how have you used it in your project?

Round-2
MCQs on Spring Boot
Modify and improve the given code
What is Reflection in Java?
.ExecutorService in Java ?
Find the second highest number in an array using Java 8
Find a file in a subdirectory
Round-3
How have you used Spring Security in your project?
What is a Spring Boot profile, and how did you use it?
What is Kafka and how have you implemented it?
Explain design patterns
What are Java 8 features?
How did you implement scheduling in your project?
How can we create an Optional of an employee object?
What is Kafka and how have you implemented it?
What is exception handling, and what is an advisor?
How does the @Transactional annotation work?
Explain microservices architecture

Java Questions -
1. What is Static Import?
2. Difference between Heap and Stack memory?
3. What is the role of the Garbage Collector?
4. Explain SRP with example?
5. What is Transient keyword?
6. How do you create a thread in Java?
7. What is the return type of the run() method?
8. Can you explain the Callable interface and how it differs from Runnable?

Microservices & API Questions 🔌


1. How would you call an API from another microservice?
2. What is Security Context, and how is it used in securing APIs?
3. How to handle errors in API communication?

SQL Questions -
1. What are Window Functions?
2. Difference between DELETE and TRUNCATE?
3. RANK() vs DENSE_RANK()?
4. Difference between HAVING and WHERE clause?
5. What is Offset?

Coding Questions -
1. Reverse a String
2. Detect cycle in a Linked List

Common questions

Powered by AI

The volatile keyword in Java ensures that the value of a variable is directly read from the main memory and not from the thread's local cache. This prevents the local memory of a thread from becoming inconsistent with the main memory when a variable is updated by one thread and accessed by others. Volatile ensures visibility of changes to variables across threads but does not guarantee atomicity; thus, it is best used for flags or states that only require visibility .

Spring Dependency Injection (DI) is a design pattern used in the Spring Framework to achieve Inversion of Control (IoC) by injecting objects into other objects, reducing the dependency on explicitly implementing them in classes. This technique facilitates the development of loosely coupled applications by allowing developers to define dependencies externally (e.g., in XML or via annotations), rather than hard-coding them, thus enhancing modularity, testability, and flexibility to adapt to changes in configuration .

In Java, a String is immutable, meaning once created, its value cannot change; this is useful in scenarios where constant values are preferred. StringBuilder and StringBuffer provide mutable sequence of characters, allowing modifications like append and insert without creating new object instances. StringBuilder is more efficient than StringBuffer when used in a single-threaded environment because it is not synchronized. Conversely, StringBuffer is synchronized, making it thread-safe and suitable for use in multi-threaded scenarios where thread safety is a concern .

Garbage Collection in Java is an automatic memory management feature that identifies and disposes of objects that are no longer in use, freeing up memory resources. It reduces the programmer's burden of manual memory management, which can avoid memory leaks and other memory-related issues. However, Garbage Collection can impact performance since its processes can introduce pauses in application execution, especially when major garbage collection events occur, leading to what is known as "stop-the-world" pauses .

ConcurrentHashMap and HashMap differ significantly in their allowance for concurrent access. While HashMap is not synchronized and not thread-safe, ConcurrentHashMap is designed for concurrent use and allows non-blocking, simultaneous read and update operations by multiple threads through segment locking. Developers should choose ConcurrentHashMap over HashMap when building applications that require high concurrency and need to ensure thread safety without the cost of synchronizing the entire map, which can degrade performance .

REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) differ both in architecture and use cases. REST is an architectural style that uses standard HTTP methods and is stateless, often preferred for microservices due to its simplicity and scalability. SOAP, on the other hand, is a protocol that uses XML-based messaging and requires strict adherence to predefined standards, making it suitable for enterprise environments where robust security and transaction compliance are needed. REST APIs can be implemented more quickly and are more easily maintained, while SOAP excels in scenarios requiring extensive security and transaction control .

The Java Development Kit (JDK) is a software development environment used for developing Java applications and applets. It includes the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc), and other tools needed for Java development. The JRE provides the libraries, Java Virtual Machine (JVM), and components to run applications written in Java, but does not include tools for developing Java applications. The JVM is an abstract machine that enables your computer to run a Java program, it is part of the JRE and executes Java bytecode. The distinctions are crucial as developers need the JDK to compile Java applications, whereas users running Java applications only need the JRE .

Java achieves platform independence through its use of the Java Virtual Machine (JVM). When Java source code is compiled, it is transformed into bytecode, a platform-independent code that can run on any operating system that has a corresponding JVM. The JVM interprets or compiles this bytecode into machine-specific instructions at runtime, thus enabling the same Java program to run on different platforms without modification .

ArrayList and LinkedList are both part of Java's Collections Framework but differ in their internal implementations. ArrayList uses a dynamic array to store elements, making it more efficient for indexed access operations like get() since it offers constant-time performance. However, adding or removing elements, particularly in middle positions, is costly due to necessary array resizing and copying operations. In contrast, LinkedList uses a doubly linked list internally, which makes insertions or deletions more efficient (constant time) when compared to ArrayList, but its indexed access operations are slower as it requires sequential access to reach an element .

Securing REST APIs in Spring Boot involves several strategies. Implementing authentication and authorization mechanisms like OAuth2 or JWT (JSON Web Tokens) ensures that only authenticated and authorized users can access the APIs. Additional common practices include using HTTPS to encrypt data transmission, applying rate limiting to mitigate the risk of DoS attacks, maintaining input validation to prevent injection attacks, and ensuring sensitive information is never exposed in URL parameters .

You might also like