Questions

Java questions

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

Avoiding Java Code in JSP with JSP 2: EL and JSTL Explained

Learn how to avoid Java scriptlets in JSP 2 using Expression Language and JSTL, with examples, best practices, and common mistakes.

javajspscriptlet

Choosing a @NotNull Annotation in Java: Validation vs Static Analysis

Learn how Java @NotNull annotations differ, when to use each one, and how to choose between validation, IDE hints, and static analysis tools.

javanullpointerexceptionnullannotations

Convert a Java Stack Trace to a String

Learn how to convert a Java exception stack trace to a string using StringWriter and PrintWriter, with examples and common mistakes.

javastack-tracetostring

Convert a List to a Map in Java 8 with Streams and Collectors

Learn how to turn a List into a Map in Java 8 using streams, Collectors.toMap, method references, and duplicate-key handling.

javalambdajava-8java-stream

Convert an Array to a List in Java: Arrays.asList, Primitive Arrays, and Safe Alternatives

Learn how to convert arrays to lists in Java, including why Arrays.asList behaves differently for primitive arrays like int[].

javaarrayslist

Create an Executable JAR with Dependencies in Maven

Learn how to build a runnable Maven JAR with all dependencies included using plugins like Shade and Assembly.

javabuildmaven-2executable-jar

CrudRepository vs JpaRepository in Spring Data JPA

Learn the difference between CrudRepository and JpaRepository in Spring Data JPA, when to use each, and what extra features JpaRepository adds.

javaspringspring-data-jpaspring-repositories

Does Java Support Default Parameter Values? Overloading and Constructor Chaining Explained

Learn how Java handles default parameter values using method overloading and constructor chaining, with examples and common pitfalls.

javamethodsparametersoverloading

Does a finally Block Always Execute in Java? Exceptions, Return, and Edge Cases

Learn when a finally block runs in Java, how it behaves with return and exceptions, and the rare cases where it may not execute.

javaerror-handlingreturntry-catch-finally

Generate Random Integers in a Range in Java

Learn how to generate random integers within a specific range in Java correctly, avoid overflow bugs, and use Random and ThreadLocalRandom safely.

javarandominteger

HashMap vs Hashtable in Java: Differences, Performance, and When to Use Each

Learn the differences between HashMap and Hashtable in Java, including thread safety, null handling, performance, and when to use each.

javacollectionshashmaphashtable

HashMap vs LinkedHashMap vs TreeMap in Java

Learn the difference between HashMap, LinkedHashMap, TreeMap, and Hashtable in Java with examples, ordering rules, and use cases.

javadictionary

Hibernate hbm2ddl.auto Values Explained: validate, update, create, create-drop, and schema strategies

Learn Hibernate hbm2ddl.auto values, what each option does, when to use update, and safer alternatives for schema changes in real projects.

javahibernatehbm2ddl

How Android SDK Finds the JDK on Windows

Learn why Android SDK setup may not detect the JDK on Windows and how Java paths, environment variables, and 32/64-bit tools affect it.

javaandroidsdkwindows-7-x64

How Java Servlets Work: Instantiation, Sessions, Instance Variables, and Multithreading

Learn how Java servlets handle instantiation, sessions, shared variables, and multithreading for multiple users and requests.

javamultithreadingservletssession-variables

How the Enhanced for-each Loop Works in Java

Learn how Java's enhanced for-each loop works, its equivalent standard loops, limitations, and when to use iterators or index-based loops.

javaforeachsyntactic-sugar

How to Add Local JAR Files to a Maven Project in Java

Learn how to use local JAR files in a Maven project, including system scope, installing to a local repository, and best practices.

javamavendependencieslibraries

How to Assert Exceptions in JUnit Tests

Learn how to test that code throws exceptions in JUnit using expected exceptions, assertThrows, and clean test patterns.

javaexceptionjunitjunit4

How to Avoid Null Checks in Java

Learn practical ways to avoid repeated null checks in Java, prevent NullPointerException, and write cleaner, safer code.

javanullpointerexceptionnull

How to Break Out of Nested Loops in Java

Learn how to break out of nested loops in Java using labeled break, flags, and cleaner control-flow patterns with examples.

javaloopsnested-loops

Page 1 of 6 - 117 questions

PreviousNext