CodeGym /Java Blog /Random /Java Exercises for Beginners
Vasyl Malik
Senior Java Developer at CodeGym

Java Exercises for Beginners

Published in the Random group
If you are looking for Java exercises for beginners, I have good news for you: it is a proper step to become a real programmer. Because programming is all about coding, and there is no way to avoid this. However, this news is a good one! Because it is really exciting to learn something practical. Sure, you need to learn theory as well, but without practice, programming theory is just a pretty boring collection of words, rules, and terms. Java Exercises for Beginners - 1

Why is practice so important?

Can you imagine a swimmer student who learns how to swim from books and internet video, but never tries swimming pool? Or a singer who reads theory again and again way before trying their voice? Well, programming is the same! Learning theory is useful, but solving Java programming exercises for beginners is a must. The short answer is very easy: the essence of programming is practice.

So, how to practice?

According to the previous paragraphs, the topic question means no less than 'how to learn Java.' The short answer is: you learn it the way that is not boring for you, and it should contain enough practical tasks. Well, very briefly:
  1. Have a plan for your learning. It could be a schedule of some courses or table of contents from a good Java book for a beginner.
  2. Connect your schedule to the time. For example, learn Java every day (or at least every other day) for 1,2,3 hours… The speed of your learning depends on your previous programming experience, education, and the time you ready to spend.
  3. Solve many java beginner exercises every day, read some lectures for them.
  4. Check the correctness of your code.
  5. Don’t hesitate to ask some questions to people who know more than you.

Where to find Java beginner's exercises and how to solve them?

It seems that you may have some new questions after reading our short plan. Which schedule to choose? Where to find Java exercises for beginners? How to check them out? CodeGym Java Course was created with these typical programming student questions in mind. Here you’ll find:
  • CodeGym course contains almost all Java Core topics and a little more, arranged in a logical order to study. Some topics are first studied superficially, then when the student is ready, they return to the topic and study it more thoroughly.
  • Short and entertaining lectures, combined with an exciting plot with elements of science fiction. They are fun so that you won’t get bored.
  • 1200+ coding tasks from the easiest to pretty tough. You’ve got the most of your tasks when you are ready to solve them. Some of them are tough. You can read more theory and turn to them later.
  • Code validator that can check your solution in a moment. If something goes wrong, you’ll get tips and recommendations to fix it up.
  • You can solve your coding exercises in the best environment for professionals - IntelliJ IDEA IDE (free Community version) with a CodeGym Plugin or right on CodeGym website (it includes Web IDE), or even on your Android cell phone (CodeGym application).
  • If you can’t solve your tasks for a long time, press the button “help” (in IDEA Plugin, CodeGym IDE, or CodeGym app). You will find yourself in the "Help" section, where you may ask questions. The other students and CodeGym curators answer them pretty quickly. Sure, you won't find here just Java Exercises with Solutions for beginners, but they help to get your problem and to solve it.
  • CodeGym seems to be a game. You have your character, a roboguy named Amigo, who learn to program from space newcomers. Amigo stars from level 0 collecting dark matter to go through, level by level to mastering Java Core. There are many game trophies as well, so we repeat it, you won’t be bored!
So, after the CodeGym course walkthrough, you’ve got 300-500 hours of practical experience.

What Java exercises should you solve?

Here we list the main topics of Java Core.

Java Syntax

Java beginners exercises. From the very first word in Java that helps you to write your first “Hello World” program to loops and conditional operators. Here you learn primitive types, how to work with them, what is class. Everything on a fundamental level right for beginners. Topics:
  • Write your very first Java programs. Keyboard output
  • Variables, methods, and classes
  • DataTypes: int, double, boolean, String
  • Keyboard input
  • Conditions and loops
  • Introduction to classes. Constructors and objects
Where to find the tasks: CodeGym level 0 to 6.

Java Collections and Data Structures

This topic is very interesting for beginners. At first, mastering some of the data structures causes difficulties for beginners, but later, they give you the flexibility to choose the right structure for your problem. So, knowing them well is a kind of superpower. Java exercises for beginners devoted to Java collections are represented on CodeGym widely. For example, CodeGym students start to learn Arrays from the level 6 of the first Java Syntax quest (for total newbies) and turn to them more deeply in Java Collections Quest (Level 7, lesson 7). Topics:
  • Arrays
  • ArrayList, LinkedList
  • HashSet, HashMap
  • Iterable
  • Collection Interface
  • List Interface and implementations
  • Map Hierarchy
  • Set Interface and implementations
  • Queue
  • Trees, Red-Black trees
  • Iterators
Where to learn and find tasks: CodeGym Quest Java Syntax, levels 7, 8 (Collections, Arrays, and Lists for beginners) CodeGym Quest Collections, levels 6, 7 Except for these tasks, sure you will use all these data structures and collections, solving almost any practical Java task.


An exception (or exceptional event) is an abnormal situation that arises during the execution of a program. In Java, Exception is a class you may work with. This mechanism greatly simplifies bug catching in programs. Topics:
  • Stack Trace
  • Exceptions types
  • Try Catch Finally construction
  • Runtime Exceptions
  • IOExceptions
  • Multi-Catch
Where to learn and find tasks: CodeGym Java Syntax Quest, level 9… and many other tasks.

Object-Oriented Programming (OOP)

Everything in Java is about an object. Hence, it is essential to understand OOP. This topic is not so difficult. Just mix your lectures and articles about OOP with a huge amount of Java tasks. CodeGym contains enough practical Java beginner exercises to help you get this object-oriented philosophy. Topics:
  • Classes and objects in general
  • condition and behavior of the object
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Overloading and overriding
  • Abstraction and abstract classes
  • Virtual Methods
  • Interfaces
  • Interface implementations
  • InstanceOf
  • Access Modifiers
  • The order of Constructor calls
Where to learn and find tasks: CodeGym Java Core Quest, levels 1, 2, 3, 4, 5.

Input/output streams

Java students use I/O streams way before having an idea of them. First Java programs, aka “ Hello World,” contain “System.out.println.” However, understanding of these “in” and “outs” comes way after the first steps. CodeGym includes a lot of content to explain the topics and even more exercises. Topics:
  • Introduction to Input/Output Streams
  • FileInputStream and FileOutputStream
  • InputStream and OutputStream
  • BufferedInputStream
  • Your own wrapper for
  • Adapter
  • Reader and Writer
  • FileReader and FileWriter
  • BufferedReader and InputStreamReader
  • Your own wrapper for System.out
Where to learn and find tasks: CodeGym Java Core Quest, levels 8, 9.


Not every newbie programmer can write a "Hello, World!" program using the Java Thread API to display the famous phrase from a separate thread. You should be prepared for this tough topic, one of the most complicated topics for beginners! Anyway, when you realize you know how to work with threads. You feel that it was an essential point of your programmer’s life. Topics:
  • What is thread
  • Creating and starting new threads
  • Join
  • Creating and stopping threads: start, interrupt, sleep, yield
  • Marker interface and deep copies
  • Synchronized, volatile
  • Deadlock, Wait. notify, notifyAll
Where to learn and find tasks: CodeGym Java Core Quest, levels 6, 7; Java Multithreading Quest.

What else?

You will find even more Java Core + topics on CodeGym. For example:
  • Object class and its methods
  • Unit testing
  • Work with Generics
  • JSON
  • Design Pattern
  • RMI and dynamic proxy
  • Annotations
If you are at the very beginning of your programming way, we wish you temperance, motivation, and good luck!
Comments (2)
Anonime1105 Level 1, Paris, France
12 May 2020
I hope to learn java in fun and intuitive way.
Parvej Mosharaf Level 1, San Francisco, United States
14 March 2020
It seems really interesting.