Questions

Java questions

Choose a question page, learn the concept, then test your understanding with a quiz.

Java ThreadLocal: When and How to Use Per-Thread Variables

Learn when to use Java ThreadLocal for per-thread state, how get, set, and remove work, and how to prevent thread-pool memory leaks.

javamultithreadingconcurrencythread-local

Java Threads: implements Runnable vs extends Thread

Learn the difference between implements Runnable and extends Thread in Java, when to use each, and why Runnable is usually preferred.

javamultithreadingrunnableimplements

Java URL Encode Query Parameters Correctly

Learn how to encode Java URL query parameters with UTF-8, handle spaces as %20, and avoid invalid URLs, double encoding, and delimiter errors.

javahttpurlencoding

Java Unicode Escapes in Comments: Why Commented Code Can Still Execute

Learn why Java processes Unicode escapes before tokenizing, allowing sequences like \u000d in comments to affect code parsing.

javaunicodecomments

Java Varargs Explained: What `String...` Means in Method Parameters

Learn what `String...` means in Java methods, how varargs work, when to use them, and how they compare to arrays.

javavariadic-functions

Java instanceof and null: Do You Need a Null Check?

Learn how Java's instanceof works with null, whether a null check is needed, and how to use it safely in real code.

javanullpointerexceptionnull

Java switch Statements with Strings: How They Work

Learn why older Java versions could not switch on String, how Java 7 added support, and how String switch compiles using hashCode and equals.

javastringswitch-statement

Java volatile Keyword: Visibility, Uses, and Examples

Learn what Java's volatile keyword guarantees, when to use it for thread visibility, and why it does not make compound updates atomic.

javamultithreadingkeywordvolatile

Linking to External URLs in Javadoc

Learn how to link to external websites in Java Javadoc with HTML anchors, and when to use @link, @linkplain, and @see tags.

javaurljavadochyperlink

Maven Dependency Versions: Latest Releases, Ranges, and Updates

Learn how Maven resolves dependency versions, why always using latest is risky, and safer ways to find and update library releases.

javamavendependenciesmaven-2

Measure Android App and Device Memory Usage Programmatically

Learn how to measure Android app memory and available device memory with ActivityManager, Debug.MemoryInfo, and practical limits.

javaandroidmemorymemory-management

Optional Parameters in Java: Practical Ways to Simulate Them

Learn how optional parameters work in Java, why Java has no true optional parameters, and the common patterns to model them cleanly.

javaoptional-parameters

Oracle JDK vs OpenJDK: Differences, JVM Options, and Garbage Collection

Learn how Oracle JDK and OpenJDK differ in licensing, release builds, support, JVM flags, and garbage collection behavior across Java versions.

javadifference

Pass Objects Between Activities in Android Java with Parcelable

Learn how to pass a Customer object between Android activities using Parcelable, Intent extras, and safe data validation in Java.

javaandroidobjectandroid-intent

Reading a Plain Text File in Java: Common Ways and Differences

Learn how to read plain text files in Java using BufferedReader, Scanner, Files, and streams, with examples and key differences.

javatextfile-ioascii

RecyclerView Multiple View Types in Android (Java)

Learn how to use multiple view types in an Android RecyclerView with Java using getItemViewType, ViewHolders, and practical examples.

javaandroiduser-interfaceandroid-recyclerview

Remove Whitespace from a String in Java

Learn how to remove whitespace inside Java strings with replaceAll(), while preserving characters such as equals signs and values.

javawhitespace

Return a Method Argument with Mockito in Java

Learn how to configure Mockito mocks to return the argument passed to a method using AdditionalAnswers and custom Answer callbacks.

javamockito

Skip Unit Tests in a Gradle Build

Learn how to run a Gradle build without unit tests using task exclusion, and understand why a custom -D property may not work.

javagradletesting

SoftReference vs WeakReference in Java

Learn the difference between Java SoftReference and WeakReference, how garbage collection treats them, and when to use each safely.

javareferenceweak-referencessoft-references

Page 7 of 9 - 166 questions