Java Practice Exercises and Coding Tasks

ExamClouds has 153 tasks for Java Core practice, split into 22 modules that follow the course: syntax, operators, control flow, arrays, OOP, the static keyword, Object methods, interfaces and enums, lambdas, the Stream API and algorithms. Many tasks come with a hint, and some with a solution and a video walkthrough. Tasks go from simple to more advanced and work for self-study, lab assignments and interview preparation.

Capstone project Online Store: from OOP to JDBC ↓

Java tasks for beginners

5 modules · 36 tasks · ~11.5 h

How to Create and Run Your First Java Application

Beginner

Practice tasks: compile and run your first Java application from the command line, pass arguments to main(), build a JAR and add it to the classpath with -cp.

☰ 2 tasks ⏱ ~1 hOpen →

Java Syntax Basics: Variables, Identifiers, and Structure

Beginner

Practice Java syntax with hands-on tasks: literals, primitive type casting table, calculator methods, and reading user input with Scanner. With solutions.

☰ 6 tasks ⏱ ~2 hOpen →

Mini project Garland: from bits to arrays

3 parts

A console garland of 32 bulbs that grows with the course: first you control the bulbs with bitwise operators in a single int, then add a mode menu with switch and loops, and finally rewrite the garland using an array.

  1. 1 32 bulbs in one int: blinking and a running light with bitwise operators Basic Operations in Java: Arithmetic and Logical
  2. 2 A mode menu with switch and repeated effects with a for loop Conditional Statements and Loops in Java (if, switch, for, while)
  3. 3 A garland on an array: a running light with System.arraycopy() Arrays in Java: How to Create and Use Them

Basic Operations in Java: Arithmetic and Logical

BeginnerGarland · part 1

Six Java operator exercises: an even number check, the minimum by absolute value, a bitwise garland, averages, a decrement countdown and a discount rule.

☰ 6 tasks ⏱ ~2 hOpen →

Conditional Statements and Loops in Java (if, switch, for, while)

BeginnerGarland · part 2

Practice Java basics with beginner coding tasks using if, switch, for, while, and do-while. Great for students and interview prep.

☰ 12 tasks ⏱ ~3 hOpen →

Arrays in Java: How to Create and Use Them

BeginnerGarland · part 3

Java array exercises for beginners: create 1D and 2D arrays, find max and min, use Arrays.binarySearch() and System.arraycopy(). With solutions.

☰ 10 tasks ⏱ ~3 hOpen →
Capstone project 11 parts

Capstone project Online Store: from OOP to JDBC

One console application that you grow from module to module: a product catalog, a cart, user login, a receipt with locale and date, saving to a file, serialization and a database via DAO.

  1. 1 Product, Category, Basket and User classes Object-Oriented Programming in Java (OOP Concepts)
  2. 2 Login, catalog and purchase with an enum and switch Interfaces and enum in Java: Object Relationships and Casting
  3. 3 Shopping Receipt with Formatting String
  4. 4 Receipt with Prices in the Current Locale Currency Localization
  5. 5 Date and Time on the Purchase Receipt Date & Time
  6. 6 Collections Instead of Arrays, Sorted Catalog Collections
  7. 7 Registration and Login Error Handling Exceptions
  8. 8 Save the Purchase Receipt to a File File Navigation and I/O
  9. 9 Inspect a Class Structure by Its Name Reflection & Java Doc
  10. 10 Online Store: Document the Classes with Javadoc Reflection & Java Doc
  11. 10 Save the Last Cart with Serialization Serialization
Works as a running lab assignment: each part builds on the previous one. Start with part 1 →

Mini project Student and Aspirant: from inheritance to reflection

4 parts

A pair of classes, Student and Aspirant, that grows with the course: first you build an inheritance hierarchy and override the scholarship calculation, then add a static counter of students in a group, and finally print the fields of any object with the Reflection API.

  1. 1 Inheritance: Student and Aspirant Object-Oriented Programming in Java (OOP Concepts)
  2. 2 A counter of Students The static Keyword in Java: Variables, Methods and Blocks
  3. 3 Universal toString() with Reflection Reflection & Java Doc
  4. 4 Student and Aspirant: Save the Group to a File (Serialization) Serialization

OOP and the standard library

12 modules · 88 tasks · ~43 h

Object-Oriented Programming in Java (OOP Concepts)

IntermediateStudent and Aspirant · part 1Online Store · part 1

17 hands-on Java OOP tasks: classes, this and super, overloading, inheritance, abstract classes, stack vs heap, garbage collection, final keyword.

☰ 16 tasks ⏱ ~9 hOpen →

The static Keyword in Java: Variables, Methods and Blocks

IntermediateStudent and Aspirant · part 2

Java static keyword exercises with solutions: count sold flowers with a static variable and build an abstract Fruit class that totals purchase cost.

☰ 3 tasks ⏱ ~1.5 hOpen →

Object Class in Java: equals() and toString()

Intermediate

Java exercises on Object class methods: default equals, hashCode and toString output, overriding toString() and equals(), and comparing objects with ==.

☰ 3 tasks ⏱ ~1.5 hOpen →

Interfaces and enum in Java: Object Relationships and Casting

IntermediateOnline Store · part 2

Java interface and enum exercises with solutions: instanceof, enums with fields, constructors and switch, abstract classes. Video walkthroughs included.

☰ 4 tasks ⏱ ~3.5 hOpen →

Wrapper Classes in Java

Intermediate

6 Java wrapper classes exercises: valueOf and parseDouble, Integer cache and == vs equals, unboxing NPE, autoboxing in loops, overloading with boxing.

☰ 5 tasks ⏱ ~2.5 hOpen →

Mini project Employee Report

4 parts

A salary report that grows with the course: formatted output, the salary payment date and writing the report to a file.

  1. 1 Employee Salary Report with Formatting String
  2. 2 FullReport Class: a Report Titled in the Locale Language Localization
  3. 2 Salary Date in the Employee Report Date & Time
  4. 4 Write the Employee Report to a File File Navigation and I/O

String

IntermediateEmployee Report · part 1Online Store · part 3

13 Java string practice problems with solutions: String methods, StringBuilder, String.format() and regex with Pattern and Matcher, plus video walkthroughs.

☰ 13 tasks ⏱ ~5 hOpen →

Localization

IntermediateEmployee Report · part 2Online Store · part 4

3 Java localization exercises: bilingual properties files, ResourceBundle, Locale and NumberFormat for currency prices, with hints and common mistakes.

☰ 3 tasks ⏱ ~1.5 hOpen →

Date & Time

IntermediateEmployee Report · part 2Online Store · part 5

7 Java date and time exercises with hints: LocalDate, LocalTime, Period, Duration, Instant and DateTimeFormatter, from age calculation to a receipt date.

☰ 7 tasks ⏱ ~3 hOpen →

Generics & Inner Classes in Java

Intermediate

10 Java generics and inner classes exercises with hints: member, local, anonymous and static nested classes, bounded types, generic methods and wildcards.

☰ 10 tasks ⏱ ~4.5 hOpen →

Lambda Expressions in Java: Syntax and Examples

Intermediate

Seven hands-on Java lambda exercises: Predicate.and, Predicate.or, Consumer.andThen, Function, Supplier and method references, with video solutions.

☰ 7 tasks ⏱ ~1.5 hOpen →

Collections

IntermediateOnline Store · part 6

10 Java collections exercises on List, Set, Queue and Map: ArrayList, TreeSet, HashSet, ArrayDeque, Iterator, HashMap. Common mistakes and hints included.

☰ 10 tasks ⏱ ~5.5 hOpen →

Reflection & Java Doc

IntermediateOnline Store · part 9Student and Aspirant · part 3Online Store · part 10

6 Java reflection exercises with hints: inspect a class by name, reflective toString(), DTO mapper, plugin loader, mini test runner and Javadoc.

☰ 7 tasks ⏱ ~4.5 hOpen →

Advanced topics

5 modules · 29 tasks · ~14.5 h

Sorting Algorithms in Java: Basics and Examples

Advanced

Nine hands-on Java algorithm exercises: array average, Fibonacci numbers, Big O complexity, the swap method, array reversal, Bubble and Selection Sort, linear and binary search.

☰ 9 tasks ⏱ ~4 hOpen →

Exceptions

AdvancedOnline Store · part 7

Java exceptions exercises with hints: validate a login and password with custom exceptions, throw and multi-catch, then build online shop registration.

☰ 2 tasks ⏱ ~2 hOpen →

File Navigation and I/O

AdvancedEmployee Report · part 4Online Store · part 8

6 Java I/O exercises with hints: copy files with try-with-resources, BufferedReader/BufferedWriter, PrintWriter reports, recursive directory listing.

☰ 6 tasks ⏱ ~2.5 hOpen →

Serialization

AdvancedStudent and Aspirant · part 4Online Store · part 10

3 Java serialization and cloning exercises with hints: Serializable and transient, a non-serializable parent, a cart saved to a file, deep copy.

☰ 3 tasks ⏱ ~3 hOpen →

Java Stream API: Complete Guide with Examples

Advanced

Nine hands-on Java Stream API exercises with Optional and Collectors: filter, map, reduce, groupingBy, joining, orElseGet. Code templates included.

☰ 9 tasks ⏱ ~3.5 hOpen →

Frequently Asked Questions

Where can I practice Java for free?

Right here: all 153 exercises on ExamClouds are free and need no registration. They follow the free Java Core course, and every task page links to the lessons it practices. Write and run the code in your own IDE, for example IntelliJ IDEA: the tasks are not tied to an online editor.

Which Java exercises should a beginner start with?

Start with the Java tasks for beginners group: your first application, syntax, operators, control flow and arrays. Then move on to OOP and the standard library, and finish with lambdas, the Stream API and algorithms. Every module card shows its level, the number of tasks and the estimated time.

Can I use these tasks as Java assignments or lab work?

Yes. The tasks are grouped by course module and go from simple to advanced, so a module works as a ready set of Java assignments or homework. The mini projects on this page grow from module to module and work well as a running lab assignment.

Are there solutions to the Java exercises?

Many tasks include a hint right under the condition, and some come with a solution on Patreon and a video walkthrough. Try to solve each task on your own first, then compare your code with the solution.

How long does it take to finish all the tasks?

Each module card shows an estimated time, from about an hour to several hours. All 153 exercises across 22 modules take roughly 69 hours of focused practice.