TOPIC-WISE INTERVIEW PRACTICE

Java interview questions and quick answers

Collections, the JVM, strings, exceptions and threads, the backbone of most campus placement rounds.

Review 867 questions and short answers on Java. Start with real examples below, then search, practise and follow links to full explanations.

867 questionsFree revision22 topics
START HERE

Java: questions worth revising first

These answers come from AI Tapri's existing question bank and published interview guides. Open each answer and read the linked in-depth guide for examples and context.

01What is the difference between ArrayList and LinkedList in Java?

ArrayList is backed by a resizable array, so reading by index is O(1) but inserting or removing in the middle shifts elements. LinkedList is a doubly linked list, so adding or removing at the ends is O(1) but reaching an index means walking the nodes. In practice ArrayList is the better default almost every time.

Read the full explanation
02What is the difference between Runnable and Callable, and what is a Future?

Runnable.run returns nothing and cannot throw checked exceptions. Callable.call returns a value and may throw. Submitting a Callable to an ExecutorService gives a Future, a handle you use to fetch the result later.

Read the full explanation
03Can a try block exist without a catch block in Java?

Yes, as long as it has either a finally block or resources in try-with-resources. A bare try with neither is a compile error.

Read the full explanation
04Can static, private and final methods be overridden in Java?

No. Final methods are forbidden from overriding, private methods are invisible to subclasses, and static methods belong to the class, so a same-named subclass method only hides the parent one instead of overriding it.

Read the full explanation
05Write a Java method to check whether a string is a palindrome, ignoring case and non-letters.

Use two pointers from both ends, skip anything that is not a letter or digit, compare lowercase characters, and move inward. It runs in O(n) time with O(1) extra space.

Read the full explanation
06Write a Java method to check whether two lowercase strings are anagrams.

If the lengths differ the answer is no. Otherwise count each letter of the first string up and each letter of the second down in an int[26], and the strings are anagrams if every count ends at zero. O(n) time, O(1) space.

Read the full explanation
07What is a common pitfall related to "What is the difference between ArrayList and LinkedList in Java"?

Saying "LinkedList is faster for insertion in the middle". The relinking is O(1), but finding the position is O(n), and in real benchmarks ArrayList's fast memory copy often wins.

Read the full explanation
08Where is "What is the difference between ArrayList and LinkedList in Java" useful in practice?

ArrayList: lists shown in a UI, search results, rows from a database, anything you mostly read or append to.

Read the full explanation
YOUR PRACTICE SPACE

Find your next answer.

Pick a topic, search a keyword, or open a question to reveal the answer.

867 questions available
JAVA

Java quick answers

Showing 18 of 867
849 remaining

Free to practise. No account needed. Made for quick revision, not rote memorisation.

Keep preparing for Java

Quick answers help with recall; detailed guides explain the reasoning, examples and common mistakes behind each answer.

More topics to practise