Top 25 Java Interview Questions for 3 Years Experience (Expert Answers)
Are you preparing for a Java interview with 3 years of experience?
This guide covers the most asked Java interview questions for 3 years experience across Core Java, Java 8, Spring Boot, Collections, and more, with clear answers and code examples.

Table of Contents
πΉ Core Java & OOPs Interview Questions
1. What are the main principles of Object-Oriented Programming?
The four core principles of OOP are:
- Encapsulation
- Inheritance
- Polymorphism
- Abstraction
2. What is the difference between ==
and .equals()
in Java?
==
checks reference equality.equals()
checks value equality
javaCopyEditString a = new String("Hello");
String b = new String("Hello");
System.out.println(a == b); // false
System.out.println(a.equals(b)); // true
3. Explain method overloading vs. overriding.
- Overloading: Compile-time polymorphism (same method name, different params)
- Overriding: Runtime polymorphism (subclass redefines parent method)
4. Can a constructor be final
?
No. Constructors canβt be final
because they are never inherited.
πΉ Java 8 & Stream API Questions
5. What is a functional interface?
An interface with exactly one abstract method.
javaCopyEdit@FunctionalInterface
interface MyFunc {
void run();
}
Used with lambda expressions.
6. What features were introduced in Java 8?
- Lambda expressions
- Stream API
- Functional interfaces
- Default & static methods in interfaces
- Optional class
- New Date & Time API
7. Stream API example to filter even numbers?
javaCopyEditList<Integer> numbers = Arrays.asList(1, 2, 3, 4);
List<Integer> evens = numbers.stream()
.filter(n -> n % 2 == 0)
.collect(Collectors.toList());
πΉ Exception Handling
8. Difference between throw
and throws
?
throw
: Used to manually throw an exceptionthrows
: Declares potential exceptions in method signature
9. Checked vs. Unchecked Exceptions?
- Checked: Checked at compile time (
IOException
) - Unchecked: Runtime exceptions (
NullPointerException
)
10. What is the finally
Block used for?
To execute code regardless of exception, often used to close resources.
πΉ Spring Boot Questions
11. What is Spring Boot?
A framework that simplifies Spring applications:
- Embedded servers
- Auto-configuration
- Minimal setup
12. Difference between @Component
, @Service
, @Repository
?
@Component
: Generic bean@Service
: Business logic@Repository
: Data access layer
13. What is dependency injection?
A design pattern where the framework injects objects into classes instead of you manually instantiating them.
14. Use of application.properties
?
To externalise configuration.
propertiesCopyEditserver.port=8080
spring.datasource.url=jdbc:mysql://localhost:3306/test
πΉ Java Collections
15. Difference between ArrayList and LinkedList?
Feature | ArrayList | LinkedList |
---|---|---|
Access time | Fast | Slower |
Insertion | Slower | Faster |
Storage | Less overhead | More memory |
16. How does HashMap work internally?
- Uses hashCode and equals
- Keys go into buckets
- Collisions handled via linked list (or tree from Java 8)
17. Difference between HashMap and Hashtable?
- HashMap: Not synchronised
- Hashtable: Synchronised, slower
πΉ Multithreading
18. Difference between synchronised method and block?
- Method: Locks the entire method
- Block: Locks only a section of code or an object
19. What is the volatile
keyword?
Ensures the variable is read from main memory, not the thread-local cache.
20. Difference between wait()
, sleep()
, join()
?
wait()
: Waits and releases locksleep()
: Waits without releasing lockjoin()
: Waits for a thread to die
πΉ Behavioural / Real-Life Questions
21. Have you used Git in projects?
Yes, for:
- Version control
- Feature branching
- Pull request-based reviews
22. How do you debug production issues?
- Log analysis
- Stack trace reading
- Tools like ELK, Splunk
23. Experience with REST APIs?
- Built using
@RestController
- JSON handling
- Consumed via
RestTemplate
orWebClient
24. Java Interview Questions for 3 Years Experience on Unit Testing
- JUnit 5
- Mockito
- Coverage via IntelliJ or Jacoco
25. Why should we hire you?
- 3 years Java experience
- Strong in Spring Boot, Java 8
- Clean code, REST, Git, Testing
- Proactive and team-driven
π More Helpful Resources
- π Java Stream API Interview Questions
- π Spring Boot Interview Questions
- β Download our Java Interview PDF
β FAQs
What topics are important for 3 years Java experience?
Core Java, Java 8, Collections, Spring Boot, REST APIs, SQL.
Is 3 years of experience enough for mid-level Java roles?
Yes. You are expected to know frameworks, APIs, OOPs, and be production-ready.
How to prepare fast for a Java interview?
Practice real Q&A, revise Java 8, do mock interviews, and study system design basics.
It is always advised to read official documents for building a better understanding.
Official Java docs:
π https://docs.oracle.com/javase/tutorial/
Spring docs:
π https://spring.io/guides
π© Got a Question?
Drop your queries in the comments or contact us here.
Weβll help you crack your next Java interview! π
One Comment