The perfect place for easy learning...

Java Programs

×

Java Programs List





Program 1

Use Eclipse or Net bean platform and acquaint with the various menus. Create a test project, add a test class, and run it. See how you can use auto suggestions, auto fill. Try code formatter and code refactoring like renaming variables, methods, and classes. Try debug step by step with a small program of about 10 to 15 lines which contains at least one if else condition and a for loop.

Program 2

Write a Java program that works as a simple calculator. Use a grid layout to arrange buttons for the digits and for the +, -,*, % operations. Add a text field to display the result. Handle any possible exceptions like divided by zero.

Program 3

Develop an applet in Java that displays a simple message.

Program 4

Develop an applet in Java that receives an integer in one text field, and computes its factorial Value and returns it in another text field, when the button named “Compute” is clicked.

Program 5

Write a Java program that creates a user interface to perform integer divisions. The user enters two numbers in the text fields, Num1 and Num2. The division of Num1 and Num 2 is displayed in the Result field when the Divide button is clicked. If Num1 or Num2 were not an integer, the program would throw a Number Format Exception. If Num2 were Zero, the program would throw an Arithmetic Exception. Display the exception in a message dialog box..

Program 6

Write a Java program that implements a multi-thread application that has three threads. First thread generates random integer every 1 second and if the value is even, second thread computes the square of the number and prints. If the value is odd, the third thread will print the value of cube of the number.Write a Java program that implements Quick sort algorithm for sorting a list of names in ascending order.

Program 7

Write a Java program that implements Bubble sort algorithm for sorting in descending order and also shows the number of interchanges occurred for the given set of integers

Program 8

Write a Java program that implements Quick sort algorithm for sorting a list of names in ascending order.

Program 9

Write a Java program to create an abstract class named Shape that contains two integers and an empty method named print Area (). Provide three classes named Rectangle, Triangle, and Circle such that each one of the classes extends the class Shape. Each one of the classes contains only the method print Area () that prints the area of the given shape.

Program 10

Write a Java program to list all the files in a directory including the files present in all its subdirectories.

Program 11

Write a Java program that correctly implements the producer – consumer problem using the concept of interthread communication.

Program 12

Write a Java program that simulates a traffic light. The program lets the user select one of three lights: red, yellow, or green with radio buttons. On selecting a button, an appropriate message with “Stop” or “Ready” or “Go” should appear above the buttons in selected color. Initially, there is no message shown.

Java program for sum of longest sequence of even numbers in an array

Given an array of numbers, you are expected to return the sum of the longest sequence of even numbers in the array.

Java program for extracting vowels and non-vowels from a string

Given an input string, you are expected to extract either all vowels, or all non-vowels from the string and return the result as all lowercase or uppercase.

Java program for finding minimum in an integer array then subtract and multiply with each element.

Given an an array of integers, you are expected to find the minimum integer in the array then subtract the same from each element of the array and multiply each element wiht the same minimum integer and return the result.

Java program for sum of longest sequence of odd numbers in an array

Given an array of numbers, you are expected to return the sum of the longest sequence of odd numbers in the array.