Java interview questions for freshers: the 10 that always come up
Ten Java questions asked in almost every fresher interview, with two-line answers you can say out loud, grouped into five easy steps.
Published by Hirastra
JDK vs JRE vs JVM, and == vs equals()
JVM runs bytecode. JRE is the JVM plus libraries needed to run programs. JDK is the JRE plus the compiler (javac) and tools. For objects, == compares references, while equals() compares content if the class overrides it, as String does.
String a = new String("hi"); String b = new String("hi"); a == b // false a.equals(b) // trueString pool, and String vs StringBuilder
Strings are immutable and literals are reused from the String pool. Concatenating in a loop creates many objects, so use StringBuilder (fast, not thread-safe) or StringBuffer (synchronized, slower). If asked why String is immutable: security, thread safety and hashCode caching.
String s1 = "hi"; String s2 = "hi"; s1 == s2 // trueArrayList vs LinkedList, and HashMap internals
ArrayList is array-backed: fast get(i), slow insertion in the middle. LinkedList has fast insert/remove at a known node but slow get(i). HashMap uses key.hashCode() to pick a bucket and equals() to find the key; long buckets become trees in Java 8+. If you override equals(), override hashCode() too.
Abstract class vs interface, overloading vs overriding
An interface is a contract and a class can implement many (default methods since Java 8). An abstract class holds shared state and code, and a class extends only one. Overloading means same name with different parameters, resolved at compile time. Overriding means a subclass redefines a parent method, resolved at runtime.
Overload = compile time. Override = runtime.Exceptions, final/finally/finalize, then practise with real openings
Checked exceptions (like IOException) must be handled or declared; unchecked ones (like NullPointerException) extend RuntimeException. final means constant or no override, finally is a block that always runs, finalize is an old garbage collection hook. Then read a real Java job description and prepare answers for the skills it lists. Today's verified openings are here:
hirastra.com/today
Skip the searching: today's verified openings are posted three times a day with official apply links, and you can check your resume against any of them with the free ATS checker.