HOME HTML EDITOR C JAVA PHP

Java Exercises

This page contains Java practice exercises for beginners and intermediate learners.

Try to solve the questions first. Then check the answer.

Exercise 1: Print Numbers from 1 to 10

Write a Java program to print numbers from 1 to 10 using a loop.

Exercise 2: Even or Odd

Write a program to check whether a number is even or odd.

Exercise 3: Find Factorial

Write a program to find the factorial of a number.

Exercise 4: Reverse a String

Write a program to reverse a string.

Exercise 5: Sum of Array Elements

Write a program to find the sum of all elements in an array.

Exercise 6: Prime Number

Write a program to check if a number is prime.

More Practice Ideas

Why Practice Exercises?

Conclusion

Exercises are the best way to master Java programming.

Tip: Try to solve without looking at the answer first!