All 58 questions

  1. What is Java, and what are its main features?

    Asked in 12 of 158 interviews · last asked Oct 10 · Concept · Junior

    Show answer

    Java is a high-level, general-purpose programming language built around classes and objects. It is statically typed and uses automatic memory management. Java code usually compiles to bytecode, which runs on a Java Virtual Machine (JVM), allowing the same program to run on different platforms.

    • Object-oriented features include encapsulation, inheritance, and polymorphism.
    • Bytecode can run on different platforms with a compatible JVM.
    • Garbage collection reclaims memory from objects that are no longer reachable.
    • Java includes exception handling, multithreading, and a large standard library.

    What the interviewer checks: The interviewer is checking whether you understand Java’s basic features and how the JVM supports portability.

    Other ways it was asked
    • “What is Java?”
    • “What are some key features of Java?”
    • “What are the key features of Java?”
  2. How do StringBuffer and StringBuilder differ, and which should you use when multiple threads modify strings?

    Asked in 8 of 158 interviews · last asked Oct 13 · Concept · Junior

    Show answer

    StringBuffer and StringBuilder both hold mutable text, but StringBuffer synchronizes its methods and StringBuilder does not. Use StringBuffer when multiple threads modify the same instance; use StringBuilder when each thread has its own instance. StringBuilder usually has less overhead. A sequence of StringBuffer method calls may still need an external lock.

    • String is immutable; StringBuffer and StringBuilder can change their contents.
    • StringBuffer protects individual method calls, not an entire sequence of calls.
    • StringBuilder is usually faster because it has no built-in synchronization.
    • Multiple threads can safely use separate StringBuilder instances.

    What the interviewer checks: The interviewer checks whether you connect thread safety to shared mutable data and understand synchronization limits.

    Common mistake (in 3 of 5 reviewed answers): Many answers forget that sharing the same instance is what makes synchronized StringBuffer the safer choice.

    Other ways it was asked
    • “What is the difference between String, StringBuilder, and StringBuffer?”
    • “What is the difference between StringBuilder and StringBuffer?”
    • “What is one key difference between StringBuilder and StringBuffer in Java, and when would you use each?”
  3. What is the difference between Java and JavaScript?

    Asked in 6 of 158 interviews · last asked Jul 2 · Concept · Junior

    Show answer

    Java and JavaScript are different languages, despite their similar names. Java is statically typed and usually runs on the JVM; JavaScript is dynamically typed and runs in browsers or environments such as Node.js. I would use Java for backend services and JavaScript for interactive web pages or Node.js services.

    • Java checks types at compile time; JavaScript checks types at runtime.
    • Java uses class-based inheritance; JavaScript uses prototypes, even when written with class syntax.
    • Both can build backend services; JavaScript also runs directly in web browsers.

    What the interviewer checks: The interviewer is checking whether you understand their type systems, runtimes, and common uses.

    Other ways it was asked
    • “What is the difference between Java and JavaScript, and when would you use each?”
    • “What is the difference between JavaScript and Java?”
  4. What is the difference between == and equals in Java?

    Asked in 5 of 158 interviews · last asked Oct 8 · Concept · Junior

    Show answer

    In Java, `==` compares primitive values or checks whether two references point to the same object. `.equals()` checks equality as defined by the object's class. By default, `Object.equals()` also checks identity, but classes like `String` override it to compare contents.

    • Use `==` for primitive value comparisons and object identity checks.
    • Use `.equals()` for logical equality when the class defines it.
    • Calling `.equals()` on null throws NullPointerException; `Objects.equals(a, b)` handles null safely.
    • When overriding `equals()`, also override `hashCode()` so equal objects have equal hash codes.
    Code
    String a = new String("hello");
    String b = new String("hello");
    System.out.println(a == b);      // false: different objects
    System.out.println(a.equals(b)); // true: same contents

    What the interviewer checks: The interviewer is checking whether you distinguish object identity from logical equality and know when to use each.

    Other ways it was asked
    • “What is the difference between `==` and `.equals()` in core Java?”
    • “What is the difference between == and the equals method?”
    • “What is the difference between == and .equals()?”
  5. Why is String immutable in Java, and how can a String variable still be reassigned?

    Asked in 5 of 158 interviews · last asked Oct 22 · Concept · Junior

    Show answer

    A String is immutable because its text cannot change after the object is created. This design allows safe sharing, including string pooling and use across threads, and keeps hash codes stable. A String variable holds a reference, so reassigning it changes which object it refers to, not the original object's text.

    • String methods such as replace return a result without changing the original object.
    • Stable contents make strings reliable HashMap keys.
    • A final String variable cannot be reassigned after initialization.
    Code
    String x = "abc";
    String original = x;
    x = "bcd";
    System.out.println(x);        // bcd
    System.out.println(original); // abc

    What the interviewer checks: The interviewer checks whether you distinguish an immutable object from a variable that refers to it.

    Other ways it was asked
    • “Why is String immutable in Java?”
    • “What is string immutability in Java?”
    • “Why are Java strings immutable, and what design considerations motivate that immutability?”
  6. What is the difference between final, finally, and finalize in Java?

    Asked in 3 of 158 interviews · last asked Sep 12 · Concept · Junior

    Other ways it was asked
    • “What is the difference between final, finally, and finalize?”
    • “What is the difference between `final`, `finally`, and `finalize`?”
    • “What is the difference between final, finally, and finalize, and what does each mean?”
  7. What is the difference between Java and Python?

    Asked in 3 of 158 interviews · last asked Oct 12 · Concept · Junior

    Other ways it was asked
    • “What is the difference between JavaScript and Python?”
    • “What is the difference between Python and Java?”
  8. What is the `this` keyword used for in Java?

    Asked in 2 of 158 interviews · last asked Aug 18 · Concept · Junior

    Other ways it was asked
    • “Why and when is the `this` keyword used in Java?”
    • “What is the purpose of the `this` keyword in Java?”
  9. What is the use of the final keyword in Java?

    Asked in 2 of 158 interviews · last asked Sep 4 · Concept · Junior

    Other ways it was asked
    • “What does the final keyword do when applied to a method in Java?”
    • “What does the final keyword do when applied to a class in Java?”
    • “What is a final variable in Java, and what does the final keyword do?”
  10. Can you explain what a string is in Java?

    Asked in 2 of 158 interviews · last asked Jul 24 · Concept · Junior

    Other ways it was asked
    • “What is a String in Java?”
  11. What is the difference between an instance variable and a class variable in Java?

    Asked in 2 of 158 interviews · last asked Jul 16 · Concept · Junior

    Other ways it was asked
    • “What is an instance variable in Java?”
  12. What are the technical differences between Java and C#, and when is each more useful?

    Asked once · last asked Jun 26 · Concept · Mid-level

    Other ways it was asked
    • “What are the technical differences between Java and C#, and when would you choose one over the other?”
  13. If a list reference is declared final in Java, can the list's contents still be changed?

    Asked once · last asked Mar 25 · Concept · Mid-level

  14. Where would you use StringBuilder and StringBuffer in Java?

    Asked once · last asked Apr 17 · Concept · Junior

  15. Which Java type should you use to represent money?

    Asked once · last asked May 25 · Concept · Junior

  16. What is the difference between creating a string with new and using a string literal in Java?

    Asked once · last asked Jul 16 · Concept · Mid-level

  17. How does BigDecimal differ from float and double in Java?

    Asked once · last asked Jul 16 · Concept · Mid-level

  18. What is integer overflow in Java, how do type conversions affect it, and why does Java have different data types?

    Asked once · last asked Aug 3 · Concept · Mid-level

  19. If you declare a variable with final, does it become a constant?

    Asked once · last asked Sep 4 · Concept · Junior

  20. In Java, what is the default initial value of an uninitialized instance int field, and does the same apply to a local int variable inside a method?

    Asked once · last asked Sep 15 · Concept · Junior

  21. In Java, when you pass an object reference to a method, can you reassign the caller's reference by setting the parameter to a new object inside the method?

    Asked once · last asked Sep 15 · Concept · Junior

  22. What are loops in Java?

    Asked once · last asked Jul 17 · Concept · Junior

    Other ways it was asked
    • “What types of loops are available in Java?”
  23. What is the difference between a normal String and a StringBuffer?

    Asked once · last asked Sep 28 · Concept · Junior

    Other ways it was asked
    • “How do Java String and StringBuffer differ internally?”
  24. What is a reference in Java?

    Asked once · last asked Oct 8 · Concept · Junior

    Other ways it was asked
    • “Can you give an example of a reference in Java?”
  25. What is Java, and what are its main characteristics?

    Asked once · last asked Feb 6 · Concept · Junior

  26. What are the differences between PHP and Java?

    Asked once · last asked Sep 8 · Concept · Junior

  27. What is a package in Java?

    Asked once · last asked Apr 8 · Concept · Junior

  28. How do you declare a static method in Java?

    Asked once · last asked Apr 8 · Concept · Junior

  29. What is an instance method in Java?

    Asked once · last asked Apr 23 · Concept · Junior

  30. What does the instanceof operator do in Java?

    Asked once · last asked Apr 23 · Concept · Junior

  31. What is the difference between primitive data types and objects in Java?

    Asked once · last asked Jun 21 · Concept · Junior

  32. What is a bitwise operator in Java?

    Asked once · last asked Jul 16 · Concept · Junior

  33. What is a variable in Java?

    Asked once · last asked Jul 16 · Concept · Junior

  34. Which do you prefer, C# or Java with Spring Boot, and why?

    Asked once · last asked Jul 16 · Concept · Mid-level

  35. What is a local variable in Java?

    Asked once · last asked Jul 16 · Concept · Junior

  36. Why might you choose not to store the parsed values in a String array?

    Asked once · last asked Jul 16 · Concept · Junior

  37. Should the amount field be stored as a String or as a numeric type?

    Asked once · last asked Jul 16 · Concept · Junior

  38. Can you explain Java?

    Asked once · last asked Jul 22 · Concept · Junior

  39. Is Java platform independent?

    Asked once · last asked Jul 22 · Concept · Junior

  40. Can you explain public static void main in Java?

    Asked once · last asked Jul 22 · Concept · Junior

  41. What are the differences between Java, C#, and JavaScript running on Node.js?

    Asked once · last asked Jul 27 · Concept · Mid-level

  42. What do you know about Java?

    Asked once · last asked Jul 29 · Concept · Junior

  43. Why is Java not 100% object oriented?

    Asked once · last asked Aug 20 · Concept · Junior

  44. Why doesn't Java expose explicit pointers or pointer arithmetic?

    Asked once · last asked Aug 20 · Concept · Junior

    Other ways it was asked
    • “Why are pointers not allowed in Java?”
  45. What is the StringBuilder class?

    Asked once · last asked Sep 4 · Concept · Junior

  46. What is a method in Java, and how does it relate to the general concept of a function?

    Asked once · last asked Sep 4 · Concept · Junior

    Other ways it was asked
    • “What are functions and methods in Java, and how do they differ?”
  47. What’s the difference between the static keyword and the final keyword?

    Asked once · last asked Sep 4 · Concept · Junior

  48. Why would you use the short type to store character counts when grouping anagrams?

    Asked once · last asked Sep 8 · Concept · Junior

  49. What are the different types of data supported in Java?

    Asked once · last asked Sep 22 · Concept · Junior

  50. Can a String be represented as a character array?

    Asked once · last asked Sep 28 · Concept · Junior

  51. What is the string pool?

    Asked once · last asked Oct 1 · Concept · Junior

  52. How do you initialize a `long` variable in Java?

    Asked once · last asked Oct 8 · Concept · Junior

  53. What is the difference between C++ and Java?

    Asked once · last asked Oct 8 · Concept · Junior

  54. What factors would lead you to choose Java for a software project?

    Asked once · last asked Oct 8 · Concept · Junior

  55. What is type inference?

    Asked once · last asked Oct 9 · Concept · Junior

  56. Is Java a programming language?

    Asked once · last asked Oct 10 · Concept · Junior

  57. What do you mean by the term “static” in Java?

    Asked once · last asked Oct 10 · Concept · Junior

  58. What is the main method in Java?

    Asked once · last asked Oct 24 · Concept · Junior

More Java interview questions

How this list is made

Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.

Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.

The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every Java interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.

158 interviews, 100 candidates, Sep 2025 to Oct 2026. Updated every month with new interviews.