Interview Q&A / Java

INTERVIEW Q&A · 72 QUESTIONS

Java interview questions

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

  1. What does the static keyword mean in Java?

    static means a member belongs to the class itself, not to any one object. A static variable has one shared copy, a static method can be called without creating an object, a static block runs once when the class is loaded, and a static nested class does not need an outer object.

    IntermediateIn-depth3 min read
  2. What 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.

    IntermediateIn-depth3 min read