Placement Prep

Most Asked Java Interview Questions, Set 1

Core Java interview questions for freshers: JDK vs JRE, == vs .equals(), overloading vs overriding, abstract class vs interface, exception handling, and collections.

By FACE Prep Team 5 min read
java interview-questions placement-prep oop java-collections

Java’s core interview questions look almost the same whether you’re applying to a service company or a product startup. Knowing eight answers thoroughly matters more than skimming twenty.

Most fresher placement technical rounds cover the same set of topics: the Java execution stack, reference equality, access control, OOP design, error handling, and the Collections framework. This article covers ten of the most consistently asked questions, in the order interviewers tend to reach for them.

Java Environment: JDK, JRE, and JVM

1. What is the difference between JDK, JRE, and JVM?

These three acronyms describe three layers of the Java execution stack. Interviewers ask this in almost every first technical round because the answer reveals whether a candidate understands how Java actually runs.

ComponentWhat It ContainsWhen You Need It
JVM (Java Virtual Machine)Bytecode interpreter; converts .class files to machine codeAlways: every Java program runs inside a JVM
JRE (Java Runtime Environment)JVM + standard class librariesWhen running Java apps without writing code
JDK (Java Development Kit)JRE + compiler (javac) + debugger + toolsWhen writing and compiling Java programs

The hierarchy is: JDK contains JRE, which contains JVM. The Oracle Java SE 21 documentation covers the full standard library that ships with the JDK.

Core Language Concepts

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

The distinction is between reference equality and content equality.

  • == compares memory addresses. It returns true only when both variables point to the exact same object in memory.
  • .equals() compares the contents of two objects. The default Object.equals() behaves like ==, but String, List, and most value-holding classes override it to compare values instead.
String s1 = new String("FACE");
String s2 = new String("FACE");

System.out.println(s1 == s2);       // false (different objects in memory)
System.out.println(s1.equals(s2));  // true (same content)

The practical rule: use .equals() for String comparisons in application code. Using == on Strings is one of the most common fresher Java bugs, and it can silently produce wrong results when the JVM string pool returns a cached object.

3. What are Java access modifiers?

Access modifiers control visibility of classes, methods, and variables. Java has four.

ModifierSame ClassSame PackageSubclassOutside Package
privateYesNoNoNo
default (no keyword)YesYesNoNo
protectedYesYesYesNo
publicYesYesYesYes

A member declared without a modifier gets default access. Use protected when you need a field accessible in subclasses but not in unrelated classes outside the package.

4. What is the difference between static and final in Java?

  • static makes a member belong to the class rather than to any specific instance. All objects of the class share a static variable. A static method can be called without creating an object first.
  • final prevents change. A final variable is a constant; a final method cannot be overridden; a final class cannot be subclassed.

Both keywords can appear together: public static final int MAX = 100; is a class-level constant, the standard way to define a compile-time constant in Java.

Object-Oriented Design

5. What is the difference between method overloading and method overriding?

Both involve methods with the same name, but they operate across different class relationships.

FeatureOverloadingOverriding
Class relationshipSame classParent and child class
ParametersMust differ (type, count, or order)Must be identical
Return typeCan differMust match (or be covariant)
Resolution timeCompile time (static dispatch)Runtime (dynamic dispatch)
static methodsCan be overloadedCannot be overridden

Overloading is about convenience: one method name, multiple signatures for different input types. Overriding is about polymorphism: a child class redefines a parent’s behavior for runtime flexibility.

6. What is the difference between an abstract class and an interface?

This is the most nuanced OOP question at the fresher level. Java 8 changed the answer by allowing default and static methods in interfaces.

FeatureAbstract ClassInterface
Concrete methodsAllowedOnly as default or static (Java 8+)
Instance variablesAllowedOnly public static final constants
ConstructorAllowedNot allowed
Multiple inheritanceNot supportedSupported
Method accessAny modifierpublic by default

The design rule: use an abstract class when you want shared state or partial implementation; use an interface when you want a contract that unrelated classes can implement independently. The 20 most-asked data structures interview questions covers related polymorphism questions that come up alongside OOP design in technical rounds.

Exception Handling and Collections

7. What are the two types of exceptions in Java?

Java exceptions divide into two categories based on when the compiler notices them.

  • Checked exceptions (compile-time): the compiler forces you to handle or declare them with throws. Examples: IOException, SQLException, ClassNotFoundException.
  • Unchecked exceptions (runtime): subclasses of RuntimeException. The compiler does not require explicit handling. Examples: NullPointerException, ArrayIndexOutOfBoundsException, ClassCastException.

Both types are handled with try-catch-finally. The finally block runs regardless of whether an exception occurred or was caught (useful for resource cleanup).

8. What is the Java Collections Framework?

The Java Collections Framework (JCF) provides ready-to-use data structures for storing and processing groups of objects. OpenJDK maintains the open-source reference implementation that most JDKs ship.

InterfaceDescriptionCommon Implementations
List<E>Ordered, allows duplicatesArrayList, LinkedList
Set<E>Unique elements onlyHashSet, TreeSet, LinkedHashSet
Queue<E>FIFO orderingPriorityQueue, ArrayDeque
Map<K,V>Key-value pairsHashMap, TreeMap, LinkedHashMap

For working code in Java and other languages, the Java programs guide has implementations of the common data-structure operations that interviewers often test.

9. What is the difference between String, StringBuilder, and StringBuffer?

StringStringBufferStringBuilder
Mutable?NoYesYes
Thread-safe?YesYes (synchronized)No
PerformanceSlowest for concatenation loopsModerateFastest
Typical use caseFixed or rarely-changed textMulti-threaded string buildingSingle-threaded string building

For repeated concatenation in a loop, use StringBuilder. Concatenating String objects inside a loop creates a new object on every iteration, which gets expensive with large data.

10. What is the difference between HashMap and Hashtable?

FeatureHashMapHashtable
SynchronizationNot synchronizedSynchronized (thread-safe)
Null keys and values1 null key, multiple null valuesNeither null keys nor null values
PerformanceFasterSlower due to synchronization overhead
Current recommendationPreferredLegacy; largely superseded

In modern Java code, if you need a thread-safe map, prefer ConcurrentHashMap over Hashtable. Hashtable dates from Java 1.0 and carries legacy design decisions that ConcurrentHashMap corrects.

What These Patterns Look Like in AI-Era Development

Java’s abstract class and interface design from Q6 appears in every major Python LLM framework. LangChain’s BaseLLM, AutoGen’s Agent protocol, and LlamaIndex’s BaseQueryEngine all use the same contract: define abstract methods, let concrete subclasses override them for specific provider behavior. The OOP fundamentals covered here transfer directly across languages.

If you want to see how that plays out when building an actual AI application, TinkerLLM is worth testing at ₹299. It gives you access to real LLM APIs so you can build before committing to a longer programme.

Primary sources

Frequently asked questions

Is Java still asked in IT company placement interviews in 2026?

Yes. Service-tier companies like Infosys, HCL, Wipro, and Cognizant consistently test core Java in their technical rounds. Product companies have moved more toward Python and Go for AI roles, but OOP fundamentals remain relevant across the board.

What is the difference between JDK, JRE, and JVM in one line?

JVM runs bytecode; JRE provides libraries plus JVM; JDK provides compiler plus tools plus JRE. You need JDK to write and compile Java; you need JRE to run a compiled Java program.

Do I need to know multithreading for a fresher Java interview?

For most IT service companies, knowing how to create a thread (extending Thread or implementing Runnable) is enough. Product companies sometimes probe synchronized blocks, wait/notify, and thread pools in technical rounds.

Which Java version should I prepare for in 2026?

Java 11 or Java 17 LTS covers everything interviewers ask at the fresher level. Java 8 topics such as lambda expressions and the stream API still appear in service-tier company technical screens.

How many Java questions appear in a typical fresher technical round?

Expect five to ten concept questions in a thirty to forty-five minute technical interview. OOP principles, exception handling, and collections appear most consistently across companies.

Build AI projects

A self-paced playground for building with LLMs.

TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.

Try TinkerLLM (₹299 launch)
Free AI Roadmap PDF