All questions
of 89Explain the difference between primitive and reference data types.
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:
Last attempt -
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
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 →
What is autoboxing and unboxing?
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:
Last attempt -
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
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 →
Explain the difference between == and equals() method.
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:
Last attempt -
- == 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)
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 →
What is the difference between String, StringBuilder, and StringBuffer?
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:
Last attempt -
- 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
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 →
What are access modifiers in Java?
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:
Last attempt -
- 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
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 →
What is the difference between static and instance variables/methods?
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:
Last attempt -
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++;
}
}
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 →
What are the four pillars of OOP?
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:
Last attempt -
- Encapsulation: Bundling data and methods together, hiding internal details
- Inheritance: Creating new classes based on existing classes
- Polymorphism: Objects of different types responding to same interface
- Abstraction: Hiding complex implementation details, showing only essential features
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 →
What is the purpose of the super keyword?
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:
Last attempt -
The super keyword refers to the immediate parent class object and is used to:
- Call parent class constructor
- Access parent class methods
- 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);
}
}
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 →
What is the difference between ArrayList and LinkedList?
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:
Last attempt -
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)
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 →
What is the difference between checked and unchecked exceptions?
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:
Last attempt -
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
}
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 →
What is the exception hierarchy in Java?
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:
Last attempt -
Throwable
├── Error (unchecked)
│ ├── OutOfMemoryError
│ └── StackOverflowError
└── Exception
├── Checked Exceptions
│ ├── IOException
│ └── SQLException
└── RuntimeException (unchecked)
├── NullPointerException
└── ArrayIndexOutOfBoundsException
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 →
What is the difference between throw and throws?
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:
Last attempt -
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");
}
}
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 →
Can we have multiple catch blocks for a single try block?
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:
Last attempt -
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
}
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 →
What is the difference between process and thread?
How can you create a thread in Java?
What is the difference between start() and run() methods?
What is the difference between stack and heap memory?
What is the difference between InputStream/OutputStream and Reader/Writer?
What is Spring Boot and its advantages?
What is the difference between @Component, @Service, @Repository, and @Controller?
What is the difference between @RestController and @Controller?
What is JDBC and its architecture?
What is the difference between unit testing and integration testing?
What are the commonly used testing frameworks in Java?
What is method overloading and method overriding?
Explain the concept of pass-by-value in Java.
What is the final keyword and its uses?
What is the difference between abstract class and interface?
What is polymorphism and its types?
Explain the concept of composition vs inheritance.
What is method hiding vs method overriding?
What is the Java Collections Framework hierarchy?
What is the difference between HashMap and HashTable?
What is the difference between HashSet and TreeSet?
What is the difference between fail-fast and fail-safe iterators?
What is the Comparable vs Comparator interface?
What are the new features in Java Collections framework (Java 8+)?
What is try-with-resources and why is it useful?
What is the difference between final, finally, and finalize?
What is synchronization and why is it needed?
What are the different ways to achieve synchronization?
What is the difference between wait() and sleep()?
What is the volatile keyword?
What is the Executor framework?
Explain the JVM memory structure.
What is garbage collection and how does it work?
What causes OutOfMemoryError and how to handle it?
What is the difference between shallow copy and deep copy?
What is serialization and deserialization?
What is the purpose of serialVersionUID?
What is the Singleton pattern and how do you implement it?
Explain the Factory pattern.
What is the Observer pattern?
What is the Strategy pattern?
What is dependency injection and how does Spring implement it?
What are the different types of Spring bean scopes?
What is Spring Security and its core features?
What is Spring Data JPA and its benefits?
How do you handle database connections in JDBC?
What is the difference between Statement and PreparedStatement?
What is connection pooling and why is it important?
What are database transactions and ACID properties?
What tools can you use for Java application profiling?
What is the difference between StringBuilder and StringBuffer performance?
What is Test-Driven Development (TDD)?
What is mocking and why is it useful?
What are Java 8 features and their benefits?
What is functional programming in Java?
What is the Stream API and its benefits?
What are annotations and how do you create custom annotations?
What is the difference between fail-fast and fail-safe in Java?
What are the new features in recent Java versions (9-17)?
What is the difference between Association, Aggregation, and Composition?
Explain the internal working of HashMap.
What happens if an exception is thrown in a finally block?
What is deadlock and how can you prevent it?
What is the difference between CountDownLatch and CyclicBarrier?
What is the Fork/Join framework?
What are the different types of garbage collectors?
What is the difference between NIO and traditional I/O?
What is Spring AOP and when would you use it?
What are the best practices for Java performance optimization?
How do you identify and fix memory leaks?
How does JVM optimize code at runtime?
What are the different types of references in Java?
What is reflection and when should you use it?
What is the Module System introduced in Java 9?
What is Spring Boot Auto-Configuration and how does it work?
What are microservices and what are the challenges in implementing them?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
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.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsLAMP
Linux, Apache, MySQL, PHPRuby on Rails
Convention over ConfigurationJAM
JavaScript, APIs, and MarkupServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQFastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseWeb3 / Ethereum
Solidity, Ethereum, Hardhat, FoundryDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.