Java Exercises
Practice Java with hands-on exercises designed to reinforce key concepts across all modules and difficulty levels. From beginner fundamentals to advanced topics, each exercise helps you apply what you’ve learned through real coding scenarios.
Use the filters to quickly find exercises by module and level, focus on specific areas, and progress at your own pace. Each exercise includes clear objectives, input/output examples, and starter code(when applicable) to guide your implementation.
Build your skills, gain confidence, and move from theory to practice with structured, real-world Java exercises.
Check Leap Year
Determine if a year is leap.
2024Output:
TRUE
Extract Year Month Day
Extract year, month and day from a date.
5/20/2024Output:
2024, 5, 20
Convert Timezone
Convert time from UTC to another timezone.
2024-01-01T10:00ZOutput:
2024-01-01T11:00+01:00
Add Days to Date
Add n days to a given date.
2024-01-01, 5Output:
2024-01-06
Days Between Dates
Calculate number of days between two dates.
2024-01-01, 2024-01-10Output:
9
Compute Average
Compute average of numbers in an array.
[2,4,6,8]Output:
5
Check Prime Number
Check if a number is prime.
7Output:
TRUE
Round Decimal Value
Round a decimal number to 2 places.
3.14159Output:
3.14
Sum Big Numbers
Compute sum of very large numbers using BigInteger.
999999999999 + 1Output:
1.00E+12
Format Currency
Format a number into currency format.
1234.5Output:
1,234.50