Career Scan

Interview practice with an AI panel

Interview questions · Freshers

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.

Looking for questions for experienced candidates? Java developer interview questions

What interviewers assess

Core concepts questions

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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

  1. 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.

  2. 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.

  3. 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.

  4. 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

  1. 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.

  2. 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.

  3. 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

  1. 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.

  2. 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.

  3. 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

How to prepare

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.

Related interview questions