Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Java Coding Practice: 90+ Exercises from Basics to Java 21
Role Play
New
1 students

Java Coding Practice: 90+ Exercises from Basics to Java 21

Write Java that passes automated tests, from OOP and streams to design patterns, concurrency and AI mock interviews
Created bySoundhar K
Last updated 10/2026
English

What you'll learn

  • Write Java methods with loops, conditionals, strings and arrays that pass automated tests built around real business scenarios.
  • Design classes with constructors, inheritance, interfaces and abstract classes, and override equals() and hashCode() correctly.
  • Pick the right collection for a task, whether that's a HashMap, TreeMap, PriorityQueue, Deque or NavigableMap.
  • Replace loops with Stream pipelines using filter, map, reduce, flatMap, groupingBy and partitioningBy.
  • Use Java 21 records, sealed interfaces, pattern-matching switch and text blocks to write shorter, safer code.
  • Implement the Singleton, Factory, Strategy, Observer, Decorator and Adapter patterns in working, tested code.
  • Fix race conditions with synchronized, AtomicInteger, ExecutorService, CountDownLatch, ConcurrentHashMap and CompletableFuture.
  • Build an order processor, a task manager and a thread-safe bank step by step, then explain your design in a mock interview.

Coding Exercises

This course includes our updated coding exercises so you can practice your skills as you learn.

See a demo
Image of coding exercise example

Course content

8 sections • 7 lectures • 32m total length
  • Overview & Beginner Foundations6:23
  • Intermediate Power Tools5:15
  • Advanced Modern Java5:34
  • E-Commerce Order Processing Capstone4:19
  • Task Management Capstone3:08
  • Banking System with Concurrency Capstone3:59
  • How to Practise3:54

Requirements

  • Basic Java syntax: you can write a class with a method, an if statement and a for loop. This course builds fluency, it doesn't teach Java from zero.
  • A browser. All 90 exercises run in the Java editor built into the course, with automated tests, so there's nothing to install.

Description

There's a point in learning Java where the syntax stops being the problem. You know what a class is, you've seen a lambda, you could explain inheritance in an interview. But when you sit down to write something real, like a report grouped by category or a counter that several threads update at once, it takes far longer than it should, and you're never quite sure the result is right. Closing that gap takes one thing: writing a lot of Java and getting told immediately whether it works.

This course is 90 coding exercises in the Java editor built into the course. Each one gives you a short business scenario and a clear method contract, the inputs, the expected output and the rules, and you write the implementation. When you submit, automated tests run against your code and tell you right away whether it passes. If you get stuck, hints point you in the right direction without handing you the answer. Every exercise was compiled and run against its tests before it went live, so when a test fails, the problem is in your code, not the exercise.

Here's what that looks like in practice. One advanced exercise describes a checkout that needs to support card, wallet and bank transfer payments, with new methods added later without touching the checkout code. You get the interface and the method you must implement. You write the Strategy classes, submit, and the tests check each payment type, an unknown type and the totals. If one test fails, you know exactly which case to look at. That loop of reading a contract, writing code and fixing what the tests catch is how fluency builds, and it's the same loop you'll run every day on a real team with real unit tests.

How the course is organized

Seven short lectures at the start walk through what each tier covers and how to practice so the work sticks. After that, it's exercises.

The beginner tier gets the fundamentals fast and correct. You'll reverse strings, check palindromes, count vowels, find maximums, remove duplicates, compute factorials and Fibonacci numbers, and write FizzBuzz properly. Then come your first classes: a Rectangle with a constructor, method overloading, an overridden method in a subclass, safe division that catches an exception, and word counting with a HashMap. A small student grade book ties the tier together.

The intermediate tier is where Java starts to feel like Java. You'll write generic methods, implement interfaces and abstract classes, throw custom exceptions, and move from loops to the Stream API with filter, map and reduce. You'll use Optional for safe lookups, keep scores sorted in a TreeMap, process tasks by priority with a PriorityQueue, validate emails with regex, model days with an enum and write binary search recursively. A few exercises cover the things interviewers like to probe: a custom Iterable, correct equals() and hashCode(), AutoCloseable for resource cleanup, a fluent builder, and checking encapsulation. A three-part library system closes the tier.

The advanced tier is modern Java. You'll define records, model shapes with a sealed interface and a pattern-matching switch, format reports with text blocks and simplify type checks with pattern-matching instanceof. Then advanced collectors such as groupingBy, partitioningBy, flatMap and joining. Six design patterns follow, each in a realistic setting: a thread-safe Singleton logger, a shape Factory, payment Strategies, an Observer for subscribers, a cost Decorator and an Adapter for an incompatible interface. Concurrency comes next, from a single thread through a synchronized fix for a real race condition, AtomicInteger, ExecutorService, CountDownLatch and ConcurrentHashMap. The tier ends with a four-part capstone where you build a generic event bus, make it safe for concurrent publishing, add filtered subscriptions and process events asynchronously with CompletableFuture.

Three capstone projects

The last 15 exercises are three standalone systems, each built over five connected steps. In the e-commerce order processor, you model products and line items, add stock validation with a custom exception and finish with a revenue-by-category report. The task management system has you build a TaskManager, complete tasks by title, filter by priority and summarize completion with partitioningBy. In the banking system, you handle deposits, withdrawals and transfers, log every transaction, make deposits thread-safe under concurrent access and produce an accounts report sorted by balance. Writing one feature on top of another is the closest an exercise gets to real development, because each step depends on the code you wrote before it.

Mock interviews

After the exercises there are five AI role plays: a junior Java developer interview, a Java backend developer interview, a coding and problem-solving interview, an advanced concepts interview and an HR and behavioral interview. You talk with an AI interviewer, answer follow-up questions and get feedback. The last one matters more than people expect. Plenty of candidates pass the technical rounds and then struggle to talk about a project, a deadline or a mistake.

Who it's for

The course suits anyone who already writes a little Java and wants to get properly good at it: students heading into technical interviews, developers coming from another language, Java developers who never moved past Java 8, and self-taught programmers who've watched more Java than they've written. If you've never seen Java syntax, take a short beginner course first. If you're preparing for algorithm-heavy rounds on trees, graphs and dynamic programming, this course covers language fluency rather than data structures and algorithms, so pair it with a dedicated DSA resource.

What you need is a browser and enough Java to write a method with a loop in it.

Open the first exercise, write it without looking anything up, and see where the tests take you.

Who this course is for:

  • Computer science students and freshers preparing for Java technical interviews and campus coding rounds
  • Developers switching to Java from Python, JavaScript or C# who want to write idiomatic Java quickly
  • Java developers still writing Java 8 style code who want hands-on practice with records, sealed types and modern streams
  • Self-taught programmers who finished a Java video course but have written very little Java on their own