Questions
Java questions
Choose a question page, learn the concept, then test your understanding with a quiz.
SoftReference vs WeakReference in Java
Learn the difference between Java SoftReference and WeakReference, how garbage collection treats them, and when to use each safely.
Spring @Component vs @Repository vs @Service: What's the Difference?
Learn the difference between Spring @Component, @Repository, and @Service, including behavior, purpose, and when each annotation should be used.
StringBuilder vs String Concatenation in Java toString()
Learn when to use StringBuilder or + in Java toString(), how Java handles concatenation, and what is best for readability and performance.
StringBuilder vs StringBuffer in Java: Differences and Performance
Learn the difference between StringBuilder and StringBuffer in Java, including thread safety, performance, and when to use each one.
Testing Classes with Private Methods, Fields, and Inner Classes in Java
Learn how to test Java classes with private methods, fields, or inner classes using JUnit without changing access modifiers.
Understanding Android UserManager.isUserAGoat(): Joke API and Practical Lessons
Learn what Android UserManager.isUserAGoat() really is, why it exists, and what it teaches about reading Android APIs safely.
Understanding serialVersionUID in Java Serialization
Learn what serialVersionUID is in Java, why Serializable classes should define it, and how it prevents deserialization problems.
Verify a Method Was Not Called with Mockito in Java
Learn how to verify that a dependency method was never called in Mockito, including never(), times(0), interaction checks, and Java test examples.
What "Could Not Find or Load Main Class" Means in Java
Learn what Java's "Could not find or load main class" error means, what causes it, and how to fix classpath, package, and main method issues.
What Is Apache Camel in Java? Beginner-Friendly Introduction
Learn what Apache Camel is, how it works with Java applications, and whether it runs independently or inside a server.
What Is Reflection in Java and Why Is It Useful?
Learn what reflection is in Java, how it works, why it is useful, and when to avoid it with practical examples for beginners.
What Is a JavaBean in Java? Properties, Getters/Setters, and Serializable Explained
Learn what a JavaBean is in Java, how it differs from a regular class, why the term exists, and what Serializable means.
What Is a Maven SNAPSHOT and Why Is It Used?
Learn what a Maven SNAPSHOT is, how it differs from a release, and why Java teams use it during active development.
What Is a Static Class in Java? Understanding Static Nested Classes
Learn what a static class means in Java, where it is allowed, how it differs from inner classes, and when to use static methods and utility classes.
What `synchronized` Means in Java: Thread Safety Explained
Learn what `synchronized` means in Java, when to use it, how it works, and how it protects shared data in multithreaded code.
When to Use LinkedList vs ArrayList in Java
Learn when to use LinkedList or ArrayList in Java, how they differ in performance, and which List implementation fits common coding tasks.
When to Use Static Methods in Java
Learn when to use static methods in Java, how they differ from instance methods, and when to call methods on a class vs an object.
Why Eclipse Says “Must Override a Superclass Method” in Java Android Projects
Learn why Eclipse shows “must override a superclass method” in Java Android projects after re-importing, and how to fix it correctly.
Why Java Compound Assignment Operators Like += Don’t Require Casting
Learn why Java compound assignment operators like += compile without explicit casts, and how they differ from normal assignment.
Why Java Has transient Fields: Serialization Explained
Learn why Java uses transient fields, how serialization works, and when to exclude fields from saved object state.