LearnThatStack Ace your next interview
Backend Development
Java.
89 Qs 13 free
Change topic Change
Drill · questions

All questions

of 89
Beginner 24
01

Explain the difference between primitive and reference data types.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Primitive types store actual values directly in memory and include: byte, short, int, long, float, double, boolean, char. They are stored on the stack and have fixed memory allocation.
Reference types store references (memory addresses) to objects located in heap memory. Examples include classes, interfaces, arrays, and enums. When you assign a reference variable, you're copying the reference, not the actual object.

int x = 10; // primitive - stores value 10
String str = "Hello"; // reference - stores memory address of String object
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

02

What is autoboxing and unboxing?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Autoboxing is automatic conversion of primitive types to their corresponding wrapper classes. Unboxing is the reverse process.

// Autoboxing
Integer num = 100; // int to Integer
List<Integer> list = new ArrayList<>();
list.add(50); // int automatically boxed to Integer
// Unboxing
Integer wrapper = 200;
int primitive = wrapper; // Integer to int
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

03

Explain the difference between == and equals() method.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • == operator: Compares references for objects (memory addresses) and values for primitives
  • equals() method: Compares the actual content/state of objects (when properly overridden)
String s1 = new String("hello");
String s2 = new String("hello");
String s3 = "hello";
String s4 = "hello";
System.out.println(s1 == s2);        // false (different objects)
System.out.println(s1.equals(s2));   // true (same content)
System.out.println(s3 == s4);        // true (string pool)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

04

What is the difference between String, StringBuilder, and StringBuffer?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • String: Immutable, thread-safe. Each modification creates a new object.
  • StringBuilder: Mutable, not thread-safe, faster for single-threaded string operations.
  • StringBuffer: Mutable, thread-safe (synchronized), slower due to synchronization overhead.
String str = "Hello";
str += " World"; // Creates new String object
StringBuilder sb = new StringBuilder("Hello");
sb.append(" World"); // Modifies existing buffer
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

05

What are access modifiers in Java?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • private: Accessible only within the same class
  • default (package-private): Accessible within the same package
  • protected: Accessible within same package and subclasses
  • public: Accessible from anywhere
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

06

What is the difference between static and instance variables/methods?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Static members belong to the class itself, not to any instance. They're loaded when the class is first loaded and shared among all instances.
Instance members belong to specific object instances and require object creation to access.

class Example {
    static int staticVar = 0;     // Class variable
    int instanceVar = 0;          // Instance variable
    static void staticMethod() {  // Can't access instance members
        // staticVar++; // OK
        // instanceVar++; // Compilation error
    }
    void instanceMethod() {       // Can access both
        staticVar++;
        instanceVar++;
    }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

07

What are the four pillars of OOP?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  1. Encapsulation: Bundling data and methods together, hiding internal details
  2. Inheritance: Creating new classes based on existing classes
  3. Polymorphism: Objects of different types responding to same interface
  4. Abstraction: Hiding complex implementation details, showing only essential features
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

08

What is the purpose of the super keyword?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The super keyword refers to the immediate parent class object and is used to:

  1. Call parent class constructor
  2. Access parent class methods
  3. Access parent class variables
class Parent {
    String name = "Parent";
    void display() { System.out.println("Parent display"); }
}
class Child extends Parent {
    String name = "Child";
    Child() {
        super(); // Call parent constructor
    }
    void display() {
        super.display(); // Call parent method
        System.out.println("Parent name: " + super.name);
    }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

09

What is the difference between ArrayList and LinkedList?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

ArrayList:

  • Dynamic array implementation
  • Fast random access O(1)
  • Slow insertion/deletion in middle O(n)
  • Better for frequent access operations
    LinkedList:
  • Doubly-linked list implementation
  • Slow random access O(n)
  • Fast insertion/deletion O(1)
  • Better for frequent modification operations
List<String> arrayList = new ArrayList<>();
List<String> linkedList = new LinkedList<>();
// ArrayList better for
String element = arrayList.get(100); // O(1)
// LinkedList better for
linkedList.add(0, "first"); // O(1)
linkedList.remove(0);       // O(1)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

10

What is the difference between checked and unchecked exceptions?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Checked Exceptions: Must be caught or declared in method signature. Checked at compile-time.
Examples: IOException, SQLException, ClassNotFoundException
Unchecked Exceptions: Runtime exceptions that don't need to be caught or declared.
Examples: NullPointerException, ArrayIndexOutOfBoundsException, IllegalArgumentException

// Checked exception - must handle
public void readFile() throws IOException {
    FileReader file = new FileReader("file.txt");
}
// Unchecked exception - optional handling
public void divide(int a, int b) {
    int result = a / b; // May throw ArithmeticException
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

11

What is the exception hierarchy in Java?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Throwable
├── Error (unchecked)
│   ├── OutOfMemoryError
│   └── StackOverflowError
└── Exception
    ├── Checked Exceptions
    │   ├── IOException
    │   └── SQLException
    └── RuntimeException (unchecked)
        ├── NullPointerException
        └── ArrayIndexOutOfBoundsException
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

12

What is the difference between throw and throws?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

throw: Used to explicitly throw an exception from method or code block.
throws: Used in method signature to declare that method might throw certain exceptions.

public void validateAge(int age) throws IllegalArgumentException {
    if (age < 0) {
        throw new IllegalArgumentException("Age cannot be negative");
    }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

13

Can we have multiple catch blocks for a single try block?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Yes, multiple catch blocks are allowed. They are evaluated in order, so more specific exceptions should come before general ones.

try {
    // risky code
} catch (FileNotFoundException e) {
    // handle file not found
} catch (IOException e) {
    // handle other IO exceptions
} catch (Exception e) {
    // handle any other exception
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

The model's verdict: “

The interactive diagram is below the answer - jump to diagram ↓

This answer is explained by a shared concept diagram - open

Tailored explanation · switch back to · ·
Point the redraw:
How well did you know this?
AI:

14

What is the difference between process and thread?

Part of Pro
15

How can you create a thread in Java?

Part of Pro
16

What is the difference between start() and run() methods?

Part of Pro
17

What is the difference between stack and heap memory?

Part of Pro
18

What is the difference between InputStream/OutputStream and Reader/Writer?

Part of Pro
19

What is Spring Boot and its advantages?

Part of Pro
20

What is the difference between @Component, @Service, @Repository, and @Controller?

Part of Pro
21

What is the difference between @RestController and @Controller?

Part of Pro
22

What is JDBC and its architecture?

Part of Pro
23

What is the difference between unit testing and integration testing?

Part of Pro
24

What are the commonly used testing frameworks in Java?

Part of Pro
Intermediate 48
25

What is method overloading and method overriding?

Part of Pro
26

Explain the concept of pass-by-value in Java.

Part of Pro
27

What is the final keyword and its uses?

Part of Pro
28

What is the difference between abstract class and interface?

Part of Pro
29

What is polymorphism and its types?

Part of Pro
30

Explain the concept of composition vs inheritance.

Part of Pro
31

What is method hiding vs method overriding?

Part of Pro
32

What is the Java Collections Framework hierarchy?

Part of Pro
33

What is the difference between HashMap and HashTable?

Part of Pro
34

What is the difference between HashSet and TreeSet?

Part of Pro
35

What is the difference between fail-fast and fail-safe iterators?

Part of Pro
36

What is the Comparable vs Comparator interface?

Part of Pro
37

What are the new features in Java Collections framework (Java 8+)?

Part of Pro
38

What is try-with-resources and why is it useful?

Part of Pro
39

What is the difference between final, finally, and finalize?

Part of Pro
40

What is synchronization and why is it needed?

Part of Pro
41

What are the different ways to achieve synchronization?

Part of Pro
42

What is the difference between wait() and sleep()?

Part of Pro
43

What is the volatile keyword?

Part of Pro
44

What is the Executor framework?

Part of Pro
45

Explain the JVM memory structure.

Part of Pro
46

What is garbage collection and how does it work?

Part of Pro
47

What causes OutOfMemoryError and how to handle it?

Part of Pro
48

What is the difference between shallow copy and deep copy?

Part of Pro
49

What is serialization and deserialization?

Part of Pro
50

What is the purpose of serialVersionUID?

Part of Pro
51

What is the Singleton pattern and how do you implement it?

Part of Pro
52

Explain the Factory pattern.

Part of Pro
53

What is the Observer pattern?

Part of Pro
54

What is the Strategy pattern?

Part of Pro
55

What is dependency injection and how does Spring implement it?

Part of Pro
56

What are the different types of Spring bean scopes?

Part of Pro
57

What is Spring Security and its core features?

Part of Pro
58

What is Spring Data JPA and its benefits?

Part of Pro
59

How do you handle database connections in JDBC?

Part of Pro
60

What is the difference between Statement and PreparedStatement?

Part of Pro
61

What is connection pooling and why is it important?

Part of Pro
62

What are database transactions and ACID properties?

Part of Pro
63

What tools can you use for Java application profiling?

Part of Pro
64

What is the difference between StringBuilder and StringBuffer performance?

Part of Pro
65

What is Test-Driven Development (TDD)?

Part of Pro
66

What is mocking and why is it useful?

Part of Pro
67

What are Java 8 features and their benefits?

Part of Pro
68

What is functional programming in Java?

Part of Pro
69

What is the Stream API and its benefits?

Part of Pro
70

What are annotations and how do you create custom annotations?

Part of Pro
71

What is the difference between fail-fast and fail-safe in Java?

Part of Pro
72

What are the new features in recent Java versions (9-17)?

Part of Pro
Expert 17
73

What is the difference between Association, Aggregation, and Composition?

Part of Pro
74

Explain the internal working of HashMap.

Part of Pro
75

What happens if an exception is thrown in a finally block?

Part of Pro
76

What is deadlock and how can you prevent it?

Part of Pro
77

What is the difference between CountDownLatch and CyclicBarrier?

Part of Pro
78

What is the Fork/Join framework?

Part of Pro
79

What are the different types of garbage collectors?

Part of Pro
80

What is the difference between NIO and traditional I/O?

Part of Pro
81

What is Spring AOP and when would you use it?

Part of Pro
82

What are the best practices for Java performance optimization?

Part of Pro
83

How do you identify and fix memory leaks?

Part of Pro
84

How does JVM optimize code at runtime?

Part of Pro
85

What are the different types of references in Java?

Part of Pro
86

What is reflection and when should you use it?

Part of Pro
87

What is the Module System introduced in Java 9?

Part of Pro
88

What is Spring Boot Auto-Configuration and how does it work?

Part of Pro
89

What are microservices and what are the challenges in implementing them?

Part of Pro

No matches

Try a different filter or search term.

Pro · $10/mo

76 of 89 Java answers are gated.

Full answers, code samples, AI explanations - simpler, deeper, or as an interactive diagram. Cancel anytime.

  • Full answers + code
  • AI explain - simpler, deeper, or visualized
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

JAM

JavaScript, APIs, and Markup

Serverless on AWS

Serverless Architecture on AWS

Cross-cutting topics 43 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.

Flutter Mobile

Flutter Cross-Platform Mobile Development

Cross-cutting topics 44 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

Web3 / Ethereum

Solidity, Ethereum, Hardhat, Foundry

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git
Big-O & Complexity Analysis Arrays, Strings & Hash Tables Linked Lists, Stacks & Queues Trees, BSTs & Heaps Graphs Sorting, Searching & Recursion Operating Systems Concurrency & Multithreading Networking for Developers Git & Version Control API Design 45 Distributed Systems Fundamentals 34

Cross-cutting topics 43 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.


Cross-cutting topics 45 topics

Interviewers also test these - they're common to every stack, whichever one you picked above.