Java interview questions for freshers
As a fresher, nobody expects you to know JVM tuning. Interviewers check three things: that your object-oriented basics are solid, that you can write and explain simple code, and that you really built the projects on your resume.
Campus and graduate interviews often combine a technical round and an HR round. The questions below cover both, and each one shows what a good answer includes.
What interviewers assess
- OOP fundamentals: classes, inheritance, polymorphism, abstraction and encapsulation
- Core Java: strings, arrays, collections and exceptions
- Writing small programs and explaining your logic step by step
- Your academic or personal projects, and what you personally did in them
Core concepts questions
Explain the four pillars of object-oriented programming with an example.
What a good answer covers: Encapsulation, inheritance, polymorphism and abstraction, each with a short concrete example (for instance a BankAccount class). Interviewers prefer one clear example over four textbook definitions.
What is the difference between an abstract class and an interface?
What a good answer covers: An abstract class can hold state and constructors and supports single inheritance; an interface defines a contract a class can implement many of, with default methods since Java 8. Say when you would choose each.
What is the difference between method overloading and overriding?
What a good answer covers: Overloading: same name, different parameters, resolved at compile time. Overriding: subclass replaces a parent method with the same signature, resolved at runtime. Mention @Override.
Why are strings immutable in Java? What is the difference between String, StringBuilder and StringBuffer?
What a good answer covers: Immutability enables the string pool, safe sharing and security. StringBuilder is mutable and fast for building strings in a loop; StringBuffer is the older synchronised version.
What happens when an exception is not caught?
What a good answer covers: It propagates up the call stack; if nothing catches it the thread terminates and the stack trace is printed. Explain try/catch/finally and when finally runs.
Coding and problem solving questions
Write a program to reverse a string without using a built-in reverse method.
What a good answer covers: A loop from the end or two pointers swapping characters in a char array. Talk through edge cases: empty string, one character, and null.
How would you find duplicate elements in an array?
What a good answer covers: Start with the simple nested-loop approach, state that it is O(n²), then improve with a HashSet for O(n). Showing that you can improve your own first answer scores well.
Check whether a number is prime. How could you make it faster?
What a good answer covers: Check divisors up to the square root, skip even numbers after 2. Explain why the square-root bound works.
When would you use a HashMap? Give an example from a program you wrote.
What a good answer covers: Key-value lookups in near-constant time, such as counting word frequencies. Linking it to your own code makes the answer believable.
About your projects questions
Walk me through your final-year project. What did you build yourself?
What a good answer covers: The problem, who it was for, the tech stack, your own part (be honest in a team project), one hard problem you solved and what you would do differently. Keep it to two minutes, then let them ask.
Your resume mentions Spring Boot / JDBC / MySQL. How did your application connect to the database?
What a good answer covers: Whatever you used, explain the actual flow: connection settings, queries or repositories, and how data reached the screen. If you only followed a tutorial, say so and show what you understood.
What was the hardest bug you fixed and how did you find it?
What a good answer covers: A real bug, the steps you took (print statements, debugger, reading the stack trace), the cause and the fix. Interviewers are checking whether you can debug on your own.
HR and motivation questions
Tell me about yourself.
What a good answer covers: Ninety seconds: your degree, the one or two projects or internships most relevant to this role, what you enjoy about development, and why this company. Don't repeat your resume line by line.
Why do you want to work as a Java developer here?
What a good answer covers: Something specific about the company's products or tech, linked to what you have already learned. Generic praise sounds rehearsed.
Are you comfortable learning new technologies or relocating?
What a good answer covers: Answer honestly, and back your willingness to learn with an example of a technology you picked up on your own.
Common mistakes
- Listing technologies on your resume that you can't answer two questions about.
- Writing code silently instead of explaining your thinking as you go.
- Giving textbook definitions of OOP with no example.
- Saying "we did" for everything in a team project, so the interviewer can't tell what you did.
How to prepare
- Revise OOP, strings, collections and exceptions until you can explain each with your own example.
- Practise 20 to 30 simple array and string problems out loud, not just on paper.
- Prepare a two-minute explanation of each project on your resume, including your exact role.
- Prepare your "tell me about yourself" answer and say it aloud a few times.
Reading questions only goes so far: the real test is answering them aloud, under follow-up questions. Career Scan builds a mock interview from your own resume and the job, then shows exactly which answers need work.
Frequently asked questions
Is Java enough to get a first job as a developer?
Java plus basic SQL, Git and one framework such as Spring Boot is a common, solid combination for entry-level roles. Strong fundamentals matter more than the number of technologies you list.
What if I don't know the answer to a question?
Say what you do know and how you would find out. Interviewers of freshers value honest reasoning far more than a confident guess that turns out wrong.
How long should I prepare for a fresher Java interview?
Most candidates need a few focused weeks to revise core Java and practise coding problems. Mock interviews help you find the gaps sooner.