Java Exercises
Exercises
Test your Java skills with exercises from all categories:
Syntax
Output text
Output Numbers
Comments
Variables
Print Variables
Multiple Variables
Variable Names
Data Types
Numbers
Boolean Types
Characters
Type Casting
Operators
Strings
String Concatenation
Strings and Numbers
Special Characters
Math
Booleans
If
If Else
Else If
Short Hand If Else
Switch
While Loops
Do While Loops
For Loops
Nested Loops
For-Each Loops
Break and Continue
Arrays
Arrays and Loops
Multidimensional Arrays
Methods
Method Parameters
Return Values
Method Overloading
Scope
Recursion
OOP
Classes/Objects
Class Attributes
Class Methods
Constructors
Modifiers
Encapsulation
Packages
Inheritance
Polymorphism
Inner Classes
Abstraction
Interface
Enums
User Input
Date
ArrayList
LinkedList
List Sorting
HashMap
HashSet
Iterator
Wrapper Classes
Exceptions
Regular Expressions
Threads
Lambda Expressions
Advanced Sorting
Files
Create and Write to Files
Read Files
Delete Files
Log in to track your progress
If you haven't already, sign up to become a W3Schooler, and get points for every exercise you complete.
As a logged on W3Schools user you will have access to many features like having your own web page, track your learning progress, receive personal guided paths, and more.
The Exercise
The exercises are a mix of "multiple choice" and "fill in the blanks" questions. There are between 3 and 9 questions in each category. The answer can be found in the corresponding tutorial chapter. If you're stuck, or answer wrong, you can try again or hit the "Show Answer" button to see the correct answer.