Skip to content
Live on Product Hunt

We just launched BrainUp on Product Hunt. Thanks for coming over!

BrainUp
  • Templates
  • Resume Guides
  • Blog
  • Pricing
  • Contact
Log inBuild Resume
  • Templates
  • Resume Guides
  • Blog
  • Pricing
  • Contact
  • Log in
Build My Resume — Free
BrainUp

Build your resume. Then build your advantage. The career productivity toolkit for your whole job search.

Products

  • Free Resume Builder
  • Cover Letter Builder
  • LinkedIn Optimizer (Premium)
  • AI Interview Prep (Premium)
  • Job Tracker (Premium)

Resources

  • Resume Templates
  • Resume Guides
  • Career Blog

Company

  • Pricing
  • Contact us

Legal

  • Terms
  • Privacy
  • Cookies

© 2026 BrainUp. All rights reserved. ·

BrainUp is a career productivity tool, not a recruitment agency. We help you prepare — we don't guarantee interviews, job offers or ATS outcomes.

BrainUp

  1. Home
  2. Core Java Interview Questions

Java interview prep

Core Java Interview Questions: The Topics Every Round Covers

Core Java interviews focus on OOP principles, String immutability, the Collections framework (especially HashMap), exception handling, multithreading basics, JVM memory and Java 8 features like streams and lambdas. Expect a short coding question on top.

Practise with AI Interview PrepSee Java developer resume
  • 18 questions answered
  • Fresher to 3 years
  • Collections and JVM
  • Java 8+

Sample answers

Definition, example, trade-off.

Interviewers move from 'what' to 'why' quickly. These answers show the follow-up thinking.

Model answers for 4 core Java questions

Typical round: 30-45 minutes, 10-15 questions plus one coding task

Q: Why is String immutable in Java? A: Immutability lets Strings be safely shared from the string pool, cached for hash codes, and used as HashMap keys and in security-sensitive places like class loading and file paths. Any change creates a new String; use StringBuilder for repeated modification.

Q: How does HashMap work internally? A: It stores entries in an array of buckets. The key's hashCode picks a bucket, and equals resolves collisions within it. Since Java 8, a bucket with many entries turns from a linked list into a balanced tree. When size passes capacity times load factor (0.75 by default), the table resizes.

Q: What is the difference between checked and unchecked exceptions? A: Checked exceptions, like IOException, must be handled or declared at compile time. Unchecked exceptions extend RuntimeException, like NullPointerException, and usually signal programming errors that should be fixed, not caught.

Q: What is the difference between == and equals()? A: == compares references for objects, while equals() compares logical content when a class overrides it, as String does. If you override equals, also override hashCode so hash-based collections work correctly.

What interviewers check

Built for scanners, humans and hiring intent.

  • OOP fundamentals

    Encapsulation, inheritance, polymorphism and abstraction with real examples are the starting point of most rounds.

  • Collections depth

    HashMap internals, List vs Set, and fail-fast iterators are asked from freshers to 5-year developers.

  • Concurrency awareness

    Threads, synchronized, volatile and ExecutorService show you can reason about shared state.

  • Modern Java

    Lambdas, streams, Optional and functional interfaces signal that you write current Java, not Java 6.

Examples

Copy the structure, not the wording.

These examples show shape and specificity. Add your own facts, metrics, tools and outcomes.

OOP and basics

  • What are the four pillars of OOP?
  • Difference between abstract class and interface?
  • What is method overloading vs overriding?
  • What is the final keyword used for?
  • Explain JDK, JRE and JVM.

Collections and concurrency

  • ArrayList vs LinkedList: when to use which?
  • HashMap vs ConcurrentHashMap?
  • What is a fail-fast iterator?
  • synchronized vs volatile?
  • Runnable vs Callable?

Coding tasks

  • Reverse a string without library methods.
  • Find the first non-repeated character in a string.
  • Count word frequency using a HashMap.
  • Remove duplicates from a list using streams.
  • Check if two strings are anagrams.

Actionable tips

Small edits that lift response rates.

Run through these before every application.

  1. 1Explain with a small exampleFor polymorphism, describe a Shape with different area() implementations rather than reciting a definition.
  2. 2Know HashMap coldHashing, buckets, equals/hashCode contract, treeification and resizing come up in most Java interviews.
  3. 3Write clean code on paperUse meaningful names and handle edge cases like null or empty input in coding questions.
  4. 4Mention the Java version you useSaying you work with Java 17 or 21 and naming one feature you use shows you keep up.
  5. 5Practise speaking answersBrainUp AI Interview Prep asks Java questions for your level and gives feedback on clarity.

FAQ

Common questions, direct answers.

What are the main features of Java?

Java is object-oriented, platform-independent through the JVM, strongly typed, garbage-collected, multithreaded and has a large standard library.

What is the difference between JDK, JRE and JVM?

The JVM runs bytecode. The JRE is the JVM plus core libraries needed to run programs. The JDK adds development tools like the compiler and debugger. Since Java 11, Oracle ships the JDK without a separate JRE.

What are the four principles of OOP?

Encapsulation (hiding data behind methods), inheritance (reusing a parent class), polymorphism (one interface, many implementations) and abstraction (exposing only essential behaviour).

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

An abstract class can have state, constructors and concrete methods, and a class extends only one. An interface defines a contract; a class can implement many, and since Java 8 interfaces can have default and static methods.

What is method overloading and overriding?

Overloading is multiple methods with the same name but different parameters in one class, resolved at compile time. Overriding is a subclass redefining a parent method with the same signature, resolved at runtime.

Why is String immutable in Java?

It allows string pooling, safe sharing between threads, cached hash codes for fast HashMap use, and security for values like file paths and class names.

What is the difference between String, StringBuilder and StringBuffer?

String is immutable. StringBuilder is mutable and fast but not thread-safe. StringBuffer is mutable and synchronised, so it is thread-safe but slower.

How does HashMap work internally?

Keys are hashed to a bucket index in an array. Collisions are stored in a list, which becomes a balanced tree when large (Java 8+). equals finds the exact key. The map resizes when size exceeds capacity times the 0.75 load factor.

What is the equals and hashCode contract?

If two objects are equal by equals(), they must return the same hashCode. Breaking this causes lost or duplicate entries in HashMap and HashSet.

What is the difference between ArrayList and LinkedList?

ArrayList uses a resizable array with fast random access. LinkedList uses nodes with fast insertion and removal at the ends but slow index access. ArrayList is the right default in most cases.

What are checked and unchecked exceptions?

Checked exceptions must be caught or declared, like IOException. Unchecked exceptions extend RuntimeException, like NullPointerException, and are not enforced by the compiler.

What is the difference between final, finally and finalize?

final prevents reassignment, overriding or inheritance. finally is a block that always runs after try/catch. finalize was an Object method called before garbage collection; it is deprecated.

What is the difference between synchronized and volatile?

synchronized gives mutual exclusion and visibility for a block or method. volatile only guarantees that reads and writes of a variable are visible across threads, without locking.

What is the Java memory model: heap vs stack?

The stack holds method frames and local variables per thread. The heap holds objects shared across threads and is managed by the garbage collector.

What are lambdas and streams in Java 8?

Lambdas are short anonymous functions for functional interfaces. Streams process collections declaratively with operations like filter, map and collect, often in fewer lines than loops.

What is a functional interface?

An interface with exactly one abstract method, such as Runnable, Comparator or Function. It can be implemented with a lambda and is often marked @FunctionalInterface.

What is Optional in Java?

Optional is a container that may or may not hold a value. It makes possible absence explicit and helps avoid NullPointerException when used for return types.

How should a fresher prepare for a core Java interview?

Revise OOP, String, collections, exceptions and Java 8 features, solve 30-40 coding problems in Java, and be ready to explain one Java project in detail.

Related guides

Keep improving your application.

  • Java Developer ResumeShow the Java work interviewers will ask about.View Java resume →
  • SQL Interview Questions for FreshersMost Java backend rounds include SQL too.See SQL questions →
  • Backend Developer ResumePresent APIs and systems built with Java.View backend resume →

Practise Java interview answers with feedback

BrainUp AI Interview Prep runs Java mock interviews for your experience level.

Start interview practiceBrowse templates

The resume builder and PDF downloads are free. AI tools are part of BrainUp Premium.