100 Java Programs for Beginners with Output (2026 Practice Guide)

Introduction

One of the fastest ways to learn Java is by solving practical programs.

Many students spend weeks watching tutorials but struggle when asked to write a simple Java program independently.

The solution is simple:

👉 Practice Java programs regularly.

In this guide, you will find 100 Java programs for beginners that help improve:

  • Logic building
  • Problem-solving
  • Coding confidence
  • Interview preparation

Whether you are preparing for college assignments, coding tests, or Java interviews, these programs will strengthen your fundamentals.


Basic Java Programs

1. Print Hello World

public class Main {    public static void main(String[] args) {        System.out.println("Hello World");    }}

2. Add Two Numbers

3. Swap Two Numbers

4. Find the Largest of Three Numbers

5. Check Even or Odd Number

6. Calculate Percentage

7. Calculate the Area of a Circle

8. Calculate Simple Interest

9. Calculate Compound Interest

10. Find Square and Cube


Conditional Statement Programs

11. Check Positive or Negative Number

12. Check Leap Year

13. Check Voting Eligibility

14. Find Maximum Number

15. Find Minimum Number

16. Check Divisibility by 5 and 11

17. Check Vowel or Consonant

18. Find the Grade of the Student

19. Electricity Bill Program

20. Profit and Loss Program


Loop Programs

21. Print First 10 Natural Numbers

22. Print Even Numbers from 1 to 100

23. Print Odd Numbers

24. Sum of Natural Numbers

25. Multiplication Table

26. Factorial Program

27. Fibonacci Series

28. Reverse a Number

29. Palindrome Number

30. Armstrong Number


Pattern Programs

31. Star Triangle Pattern

32. Pyramid Pattern

33. Diamond Pattern

34. Floyd’s Triangle

35. Number Pyramid

36. Hollow Rectangle

37. Butterfly Pattern

38. Pascal Triangle

39. Right Angle Triangle

40. Inverted Pyramid


Array Programs

41. Sum of Array Elements

42. Largest Element in Array

43. Smallest Element in Array

44. Reverse an Array

45. Sort Array in Ascending Order

46. Sort Array in Descending Order

47. Find Duplicate Elements

48. Merge Two Arrays

49. Search Element in Array

50. Copy Array Elements


String Programs

51. Reverse a String

52. Check Palindrome String

53. Count Vowels

54. Count Words

55. Remove Spaces

56. Convert Uppercase to Lowercase

57. Compare Two Strings

58. Find Duplicate Characters

59. Replace Character

60. Check Anagram


Function Programs

61. Add Numbers Using a Function

62. Swap Numbers Using a Function

63. Find Maximum Using Function

64. Find Minimum Using Function

65. Check Prime Number Using Function

66. Calculate Factorial Using Function

67. Calculate Power Using Function

68. Find Area Using Function

69. Count Digits Using Function

70. Reverse Number Using Function


Object-Oriented Programming Programs

71. Class and Object Example

72. Constructor Example

73. Method Overloading

74. Method Overriding

75. Single Inheritance

76. Multilevel Inheritance

77. Hierarchical Inheritance

78. Encapsulation Example

79. Abstraction Example

80. Interface Example


Advanced Java Programs

81. Exception Handling

82. File Handling

83. Read File

84. Write File

85. ArrayList Example

86. LinkedList Example

87. HashMap Example

88. TreeMap Example

89. Stack Implementation

90. Queue Implementation


Interview Programs

91. Prime Number

92. Fibonacci Series

93. Armstrong Number

94. Palindrome

95. Number Pattern

96. String Reverse

97. Duplicate Characters

98. Array Sorting

99. Binary Search

100. Linear Search


Why Practice Java Programs?

Practicing Java programs helps students:

  • Build strong programming logic
  • Prepare for coding interviews
  • Complete college assignments
  • Improve debugging skills
  • Learn Java faster

Many companies ask variations of these programs during internships and fresher interviews.


Frequently Asked Questions

How many Java programs should beginners practice?

Beginners should start with at least 30–50 basic Java programs before moving to advanced concepts.

Are Java programs important for interviews?

Yes. Most fresher interviews include Java programming questions based on loops, arrays, strings, and functions.

Is Java still worth learning in 2026?

Yes. Java remains one of the most widely used programming languages for enterprise applications, Android development, and backend systems.


Final Thoughts

Learning Java becomes easier when you focus on practical coding instead of only watching tutorials.

Start with basic Java programs, gradually move to arrays, strings, OOP concepts, and interview questions.

Consistent practice is the fastest way to become confident in Java programming.


Core Java Tutorial

Written by Shubhranshu Shekhar, who has trained 20000+ students in coding.