Java Programs for Practice

Number Based Logical Programs

1. Java program to find perfect numbers


2. Java program to print perfect numbers from 1 to 1000

3. Java program to split number into digits.

4. Java program to swap two array.

5. Java program to find NCR factor of given number.

6. Java program to find generic root.

7. Add two number without using addition operator.

8. Java program to sum digits of a number.

9. Java program to reverse a number.

Number System and Conversion 

1. Java program for multiplication of two binary numbers.

2. Java program for addition of two binary numbers.

3. Java program for binary to hexadecimal conversion.

4. Java program for binary to decimal conversion.

5. Java program for octal to binary conversion.

6. Java program for octal to decimal.

7. Java program to convert decimal to binary number.

8. Java program to convert decimal to octal number.

9. Java program to convert decimal to hexadecimal number.

Series Based Programs

1. Java program to find out the sum of A.P. series.

2. Java program to calculate the sum of GP series.

3. Java program to find out the sum of given H.P. Series.

4. Print Sum of series 1+ (1+2) + (1+2+3).... (1+2+3+....n)

5. Print Sum of Series (1/1^2) + (1/2^2) + (1/3^2)....1/n^2

6. Print sum of series (1/1^3) – (1/2^3) + (1/3^3)....1/n^3

7. Print Series 1, 11, 111, 1111....n terms in Java.

8. Print Series 1, 12, 123, 1234.....n in Java.

9. Print Series 1, -3, 5, -7.....n terms in Java.

10. Print Series 2, -4, 6, -8....n terms in Java

11. Java program to print Tribonacci Series.

12. Java program to print fibonacci series.

String Based Programs

1. Program to find the frequency of one string in another.

2. Java program to remove vowels from a string.

3. Program to remove common characters from two strings.

4. Program to finding Shortest and Longest Words in a String.

5. Java program to reverse a String without using direct method.

6. Java program to input name, middle name and surname of a person and print only the initials.

7. Program to remove duplicates characters from given String.

8. Java program to count the occurrence of any character in given String.

9. Java program to find palindromic substring in a string.

10. Java program to accept a string and print each character of the string along with its ASCII code.

Common Logical Programs

1. Java program to find whether given no. is Armstrong or not.

2. Generate prime numbers between 1 & given number

3. Calculate Factorial of a number using recursion

4. Java program to check Palindrome Number.

5. Java program to calculate the Simple Interest.

6. Java program to show all function of bank and generate account number dyanamically.

7. Java program to find out the HCF and LCF.

8. Java program to test the Prime number.

9. Java program to Demonstrate Type Casting.

10. Find the average, sum, min and max of the N numbers Using user Input in Java.

Servlet Based Programs

1. Write a servlet which accepts client request and display the client requested data on the browser?

2. Write a servlet which accepts product details from html form and stores the product details into database?

3. Develop a flexible servlet that should display the data of the database irrespective driver name, table name and dsn name?

4. Write a servlet which retrieves the data from database?

5. Write a servlet which illustrate the concept of ServletContext?

6. Write a servlet which displays current system date and time?

7. Write a servlet which displays a message “I LOVE MY MOM”?

8. Write a servlet which retrieves the data from database?

JDBC Based Programs

1. Write a java program to create a table through frontend application?

2. Write a java program which illustrates the concept of Batch processing?

3. Write a java program which illustrates the concept of updatable ResultSet?

4. Write a java program which illustrates the concept of scrollable ResultSet?

5. Write a java program which points the data of a table along with its column names?

6. Write a java program which illustrates the concept of resource bundle file or how to develop a flexible jdbc application along with its metadata?

7. Write a java program which illustrates the concept of DatabaseMetaData and ResultSetMetaData?

8. Write a jdbc program to retrieve the data from excel?

9. Write a java program which illustrates the concept of procedure?

10. Write a java program which illustrates the concept of function?

11. Write a java program to retrieve the records from a specified database by accepting input from keyboard?

12. Write a java program to insert a record in dept database by accepting the data from keyboard at runtime using dynamic queries?

13. Write a java program to retrieve the data from emp database?

14. Write a jdbc program which will insert a record in the Student database?

Reflection Based Programs

1. Write a java program which will de-Serializable from the specified file?

2. Write a java program which will save the Serializable sub class object into a file?

3. Write a java program to print fields or data members of a class?

4. Write a java program to obtain constructors of a class?

5. Write a java program to obtain information about methods which are present in a class?

6. Write a java program to print super class hierarchy at a current class which is passed from command prompt?

7. Write a java program to find name of the class and its super class name by passing the class name at runtime?

8. Write a java program to print name of the current class and its super class name?

Logical Programs

1. How can you determine if String has all Unique Characters.?

2. How to reverse a String without using any direct method.?

3 How to convert String to integer without using any direct method in Java.?

4. How to find the missing values from an sorted array.?

5. How to reverse an array without using any built in method and any other array.?

6. How to remove specific character from an String in Java.?

7. How to find the caller of a method in Java.?

8. How to call private method from another class in java.?

Matrix Based Program

1. Addition , Substraction and trace of two Matrix in Java.

2. Find the Transpose of given Matrix in Java.

3. Program for Matrix multiplication in Java.

4. Calculate the Sum of the Elements of each Row & Column of given Matrix in Java.

5. Check if a given Matrix is an Identity (Unit) Matrix or not in Java

6. Find the Frequency of Odd & Even Numbers in the given Matrix in Java

7. Determine if a given Matrix is a Sparse Matrix in Java.

Pyramid Based Programs

1. Write a program to generate a following #'s triangle:



2. Write a program to generate a following @'s triangle:



3. Write a Java program to print the following triangle:




4. Write a Java program to display the following rhombus symbol structure:



5. Write a Java program to display the following number rhombus structure:



6. Write a Java program to print the following number pyramid:





7. Write a Java program to display the following character rhombus structure: