To understand Programming, you must practice and understand the programming logic for any programming language. Java programs are frequently asked in Interviews. This page covers maximum java programs from basic programs to an array, string, loops, and more.
1 2 3 4 5 6 7 8 9 10 11 | //HelloWorld is the name of our class public class HelloWorld { public static void main(String args[]) { System.out.println("Hello World"); } } //Output: Hello World |
This page covers the java program’s questions from basics programming to files related to java programming questions. Click the link below.
Content:
- Basics Programs
- Number Programs
- Special Number Programs
- OOP’s Programs
- Conversion Programs
- Arrays Programs
- Loops Programs
- Decision Making Programs
- Patterns Programs
- String Programs
- Files Programs
- Sorting Programs
- AWT Programs
Java Basic Programs
- Java Program to Add Two Numbers.
- Java Program to find the product of Two numbers.
- Java Program to Calculate the Area and Circumference of a Circle.
- Java Program to Check for Leap Year
- Java Program to Calculate the Area of a Rectangle.
- Java Program to Calculate the Area of a Square.
- Java Program to Calculate the Area of a Triangle.
- Java Program to Calculate the Simple Interest.
- Java Program to Calculate Grade of Students
- Java Program to make a Calculator using a Switch Statement.
- Java Program to Check Whether the Given Number Is Binary or Not.
- Java Program to print ASCII value of a Character
- Menu Driven Program in Java
- Currency Conversion Program in Java
- Java Program to Find the Distance between Two Points
- Java Program to Find Smallest of Three Numbers Using Ternary Operator
Java Numbers Programs
- Java Exercise: How to Divide in Java.
- Java Program to Swap Two Numbers Without using the Third Variable
- Java Program to Swap Two Numbers using the Third variable
- Java Program to Reverse the Number
- Java Program to Generate Fibonacci Series
- Java Program to Check Armstrong number
- Java Program to check whether a Number is Prime or Not
- Java Program to Generate Random Numbers.
- Java Program to Find the Sum of Natural Numbers.
- Java Program to Find a Factorial of a Number.
- Java Program to Find a Factorial of a Number using Recursion.
- Java Program to Find the Sum of the Digits of a Number.
- Java Program to Check Positive or Negative Numbers.
- Java Program to check whether the Number is Palindrome or not.
- Java Program to Check whether the Number is Odd or Even.
- Java Program to Display the Odd Numbers.
- Java Program to Find the Greatest of Three Numbers.
- Java Program to Find the LCM of Two Numbers.
- Java Program to Find GCD of Two Numbers.
- Java Program to find the Square Root of a Number
- Perfect Square Program in Java
- Java Program to Print Multiplication Table
Java Special Numbers Programs
- Java Program for Special Number
- Automorphic Number Program in Java
- Java Program to check whether the Number is Happy Number or Not.
- Tech Number Program in Java
- Sunny Number in JAVA
- Peterson Number in Java
- Fascinating Number in Java
- Keith Number in Java
- Neon Number in Java
- Spy Number in Java
- Java Program to Display the ATM Transaction
- Autobiographical Number in Java
- Java Program to Check if the given number is Emirp Number or not
- Sphenic Number in Java
- Buzz Number in Java
- Magic Number Program in Java
- Duck Number Program in Java
- Evil Number in Java
- Java Program for ISBN Number
- Java Program to check Krishnamurthy Number
- Bouncy Number Program in Java
- Mystery Number in Java
Java Object-Oriented Programs
- Abstraction Example in Java
- Encapsulation Example in java
- Polymorphism Example in Java
- Inheritance Example in Java
- Java Program for Super keyword
- Example of Constructor in Java
- Java example of Inner Class
- Example of this keyword in Java
- Example of Method Overriding and Overloading in Java
Java Conversion Programs
- Java Program to Convert Decimal to Binary using Recursion
- Java Program to Convert Decimal to Binary using Loop
- Java Program to Convert Binary to Decimal
- Java Program to Convert Binary to Octal
- Java Program to Convert Octal to Binary Number
- Java Program to Convert Decimal Number to Octal Number
- Java Program to Convert Octal Number to Decimal Number
- Java Program to Convert Decimal to Hexadecimal using Recursion
- Java Program to Convert Decimal to Hexadecimal
- Java Program to Convert Hexadecimal to Decimal
- Java Program to Convert Binary to Hexadecimal
- Java Program to Convert Hexadecimal to Binary
Java Arrays Programs
- Java Program to Copy one Array to another
- Java Program to Sum all the Elements in an Array.
- Java Program to Merge Two Arrays
- Reverse an Array in Java
- Reverse an Array in Java using Recursion
- Java Program to Sum all the Elements in an Array (user inputs).
- Three Dimensional Array Program in Java
- Java Program to Find the Largest Element in an Array.
- Java Program to Calculate Average of Elements in an Array
- Java Program to Insert an Element in a Specified Position in an Array.
- Java Program for the Addition of Two Matrices.
- Java Program for the Subtraction of Two Matrices.
- Java Program for the Multiplication of Two Matrices.
- Java Program to Find the Transpose of a Matrix.
- Java Program to Remove Duplicates from ArrayList
- Java Program to Find the Second Largest Number in an Array.
- Java Program to Sort Elements in Ascending Order of an Array
- Java – Get Subarray between Specified Indexes
- Find a pair with the Given Sum in an Array in Java
- Sum of rows and columns in 2d Array in Java
- Java Program to Find pair of Integers in Array whose sum is given Number
Java Loops Programs
while loop
- Java Program a Simple Demonstration of using While Loop.
- Java Program to check the number for Palindrome using a while loop.
- Java Program to Find the Sum of Natural Numbers using While loop.
- Java Program to Reverse the Number using a while loop.
do-while loop
- Java Program a Simple Demonstration of using do-while Loop.
- Java Program to Count Backward of a Number using a do-while loop.
- Java Program to Generate First n Whole Numbers using a do-while loop.
for loop
- Java Program a Simple Demonstration of using for Loop.
- Java Program to Calculate Average of Elements in an Array
- Java Program to Find a Factorial of a Number using for loop.
- Java Program to List Even Numbers within a Range.
- Java Program to List the Odd Numbers using for loop.
- Java Program to list Prime Numbers using for Loop.
Java Decision-making statements Programs
- Java Program a Simple Demonstration of using if statement.
- Java Program a Simple Demonstration of using the if-else statement.
- Java Program a Simple Demonstration of using the if-elseif statement.
- Java Program to Check for the Negative Number.
- Java Program to Find the Greatest of Three numbers using if-elseif statement.
Switch statement
- Java Program to Calculate the Area of Different Geometric Figures.
- Java Program to Calculate Simple Interest, Amount and Compound Interest using a Switch.
- Java Program to Convert Fahrenheit to Celsius and Vice-Versa.
- Java Program to Create a Calculator using Switch Case.
Java Pattern Programs
Star Patterns in Java
- Java Program to Print Pyramid Pattern of Stars
- Java Program – Top 10 Different Star Pattern Programs.
- Java Program to Print Diamond Pattern
- Java Program to print Hollow Rectangle or Square star patterns
- Java Program to Print Hollow Rectangle Pattern of Stars
- Java Program to Print Right Triangle Star Pattern
- Java Program to Print Left Triangle Star Pattern
- Java program to print Inverted Equilateral Star Triangle
- Hollow Pyramid using Stars in Java
- Hourglass Star Pattern in Java
- Right Arrow Star Pattern in Java
- Hollow Diamond Pattern in Java
- Hollow Inverted Right Triangle Star Pattern in Java
- Half Hourglass Star Pattern in Java
- Inverted Hollow Pyramid using Stars in Java
Number Patterns in Java
- Java Number Pattern (Hill shape 1)
- Java Number Pattern (Hill shape 2)
- Java Program – Top 10 Different Number Pattern Programs.
- Java Program to Print Floyd’s Triangle
- Java Program to Print Pascal Triangle
- Java Program to print Even Odd number Pyramid
- Java Program to Print Odd Number Pyramid
- Java Program to print Half Pyramid using Numbers
- Inverted Half Pyramid using Numbers in Java
- Triangle Pattern with Repeated Digits in Java
- Inverted Triangle Pattern in Java with Descending Order
- Right Triangle Pattern of Numbers in Java with Repeating Pattern (Mirror image)
- Mirror Image Triangular Number Pattern in Java
- Hourglass Number Pattern in Java
- Inverted Hourglass Pattern in Java using Numbers
- Square Number Pattern in Java: 1
- Square Number Pattern in Java: 2
- Square Number Pattern in Java: 3
- Square Number Pattern in Java: 4
- Square Number Pattern in Java: 5
- Square Number Pattern in Java: 6
- Square Number Pattern in Java: 7
- Square Number Pattern in Java: 8
- Square Number Pattern in Java: 9
- Square Number Pattern in Java: 10
Alphabet Patterns in Java
- Java Program – Top 10 Different Alphabetic Pattern Programs.
- Alphabet Pyramid Pattern in Java: pattern 1
- Alphabet Pyramid Pattern in Java: pattern 2
- Alphabet Pyramid Pattern in Java: pattern 3
- Reverse Pyramid with Alphabet in Java
- Similar Alphabet Pyramid Pattern in Java
- Java Program to print Half Pyramid using Alphabets in Increasing order
- Inverted Right Triangle Alphabet Pattern in Java: Pattern 1
- Inverted Right Triangle Alphabet Pattern in Java: Pattern 2
- Inverted Right Triangle Alphabet Pattern in Java: Pattern 3
- Inverted Right Triangle Alphabet Pattern in Java: Pattern 4
- Inverted Right Triangle Alphabet Pattern in Java: Pattern 5
- Inverted Right Triangle Alphabet Pattern in Java: Pattern 6
- Right Angle Triangle Character Pattern in Java: Pattern 1
- Right Angle Triangle Character Pattern in Java: Pattern 2
- Right Angle Triangle Character Pattern in Java: Pattern 3
- Right Angle Triangle Character Pattern in Java: Pattern 4
- Right Angle Triangle Character Pattern in Java: Pattern 5
- Alphabet Pattern Programs in Java (Diamond Shape)
- 2 Different Alphabet Patterns in Java (sideways triangle)
- 2 Different Alphabet Patterns in Java (half hourglass)
- Half Repeated Character Pattern in Java
- Java Character Pattern Program
String Patterns in Java
- Java String Pattern: 1
- Java String Pattern: 2
- Java String Pattern: 3
- Java String Pattern: 4
- Java String Pattern: 5
- Java String Pattern: 6
- Java String Pattern: 7
- Java String Pattern: 8
- Java String Pattern: 9
- Java String Pattern: 10
Java Strings Programs
- Java Program for user String Input.
- Java Program to Check if the String is empty or not.
- Java Program to Check the String for Palindrome.
- Java Program to Reverse a String.
- Java Program – How to Reverse Sentences in String.
- Java Program to Count Letters in a String.
- Java Program to Count the Number of Words Present in a text file.
- Java Program to Find a Frequency of Words.
- Java Program to Count Total Character in a String.
- Java Program to Find the Frequency of a Character
- Java Program to Find the Number of Vowels and Consonants in a String.
- Java Program to Check Whether Two Strings are Anagram Or Not.
- Java Program to find the Duplicate Characters in a String.
- Java Program to Remove all White Spaces from a String.
- Java Program to Count the Number of Words present in a String using HashMap.
- Java Program to Remove all the Vowels from a String.
- Java Program to Sort String in an Alphabetical order
Java Files Programs
- Java Program to Append Content into a File.
- Java Program to Check Whether a New file is Created or Already Exists.
- Java Program to Copy Content from one File to another File.
- Java Program to Count the Number of Lines in a File.
- Java Program to Count the Number of Words in a File.
- Java Program to Read Char by Char from a File.
- Java Program to Read in a File Line by Line.
- Java Program to Search a Particular Word in a File.
- Java Program to Write Char by Char into a File.
- Java Program to Write in a File Line by Line.
Java Sorting Programs
- Bubble Sort in Java
- Selection sort in Java
- Heap Sort in Java
- Insertion Sort in Java
- Quick Sort in Java
- Merge Sort in Java
- Shell Sort in Java
- Counting Sort in Java
Java AWT Programs
- Java Program to Create Login Window using AWT Controls
- Java Program to Create a Calculator Using AWT Controls