Core Java (Example)

 List of Programs for Journal

Write a java program to print Hello Java.
Write an Application program to print your name and address.
Write a java program to create a class Rectangle having two member variables length and breadth. Display the area and perimeter of a rectangle by appropriate methods.
Create one integer array of size 10 and initialize the array with some values. Write a program to arrange the entire array into its ascending order and display the sorted array.
Write an Application program to find matrix multiplication.
Write a java program to create a class named circle having member radius, also create two methods for getting area and circumference of a circle. Initialize the member radius by constructor and setRadius() method.
Write a java program to create a class named BOX that includes integer data fields for length, width and height. Create three constructors which require 1, 2, 3 arguments. When one argument is used, assign it to length, assign 0 to height and width and print “line created”. When two arguments are used, assign them to length and width, assign 0 to height and print “Rectangle created”. When three arguments are used then assign them to three variables and print “Box created”.
Write a program that defines circle class with two constructors. The first form accepts a double value that represents radius of circle. This constructor assumes that circle is centered at the origin. The second form accepts three double values. The first two arguments define co-ordinates of center. And third value defines radius.
Write menu driven an Application program for following string manipulation.Reverse a string.Sorting (using a string)Conversion from upper to lower and vice-versa.Exit.
You are given a sting str =”sardar patel university”. Perform the following operation on it.

  1. find the length of string
  2. replace the character p’ by ‘r’
  3. convert all character in uppercase

Extract and print “sardar” from given string.

Write an Application program that search through its command-line arguments if an argument is found that does not begin with an Uppercase letter display an error message and terminate.
Write an Application program to find matrix multiplication table for example.1   2    3————-1 |  1   2   32 |  2   4   63 |  3   6   9Note: use command-line arguments(R C)
Write a program for Hardware company. Ask the user to choose F for Floppy, C for CD, P for Pen drive. Show the price of each item. Show price of a hardware manufactured with the chosen wood. Floppy price is 15 Rs., CD price is 20 Rs and Pen drive price is 1250 Rs. The class name is Hardware
Write a menu driven an Application program.

  1. Check for positive or negative number
  2. Check for odd or even number
  3. Check for primary number
  4. Check for Palindrome number
  5. Check for Armstrong number
  6. Check for number whether a member of Fibonacci series
  7. Exit

Create abstract methods for every check into abstract Proto1 class and define into Defi1 class and call from Menu1 class.

Write a java program to count integer and non-integer passed by user through readLine() method
Write a java program to create an Equipment class. Derive two subclasses from the equipment class by the name Pump and Tank. Take appropriate attributes and methods for all the above classes and print the details.
  Write a java program to create the class Trust and create two subclasses of class Trust by name College and Hospital take appropriate attributes and methods for all above classes and print the data.
Create an abstract class Auto with fields for the car make and price. Include get and set methods for these fields; the setPrice() method is an abstract. Create two subclasses for individual automobile makers and include appropriate setPrice() methods in each subclass. Finally, write a program that uses the Auto class and subclasses to display information about different cars
Create a class named Square that contains data fields for height, width, and surfaceArea, and a method named computeSurfaceArea(). Create child class Cube. Cube contains an additional data field named depth, and a computeSurfaceArea() method that overrides the parent method. Write a program that instantiate a Square object and a Cube object and display the surface areas of the objects.
Write an Application program and create one class that accepts an array of ten numbers create one subclass which has following,-          Display numbers entered-          Sum of the numbers-          Average of numbers-          Maximum of numbers-          Minimum of numbers-          Exit

Create appropriate methods in the subclass to execute operation as per our choice.

Note: use super keyword.

5 candidates contest an election. The candidates are numbered 1 to 5 and making the candidate number on the ballot paper does the voting. Write a program to read the ballots and count the votes cast candidate using an array variable count. In case, a number read is outside the range 1 to 5, the ballot should be considered as a ‘spoilt ballot’ and the program should also count the number of spoilt ballots.
Write a java program to count the number of occurrences of a particular character in entered string.
Write a java program to count the number of occurrences of a word in a string.
Given are two one-dimensional arrays, which are sorted in ascending order. Write a program to merge them into a single sorted array that contains every item from both the arrays in ascending order.
Write a java program to accept two integers through command line argument and perform the arithmetic operation on them.
Write a java program that gives the list of valid and invalid integers using command line arguments.

   Input : 112 java 23.2 3434

  Output: valid integers:2 invalid integers :2

Write a menu driven an Application program to do following.Member variable:  std_no,std_name,std_sub1,std_sub2,std_sub3,total,per

  1. New Student Entry
  2. Calculate student result
  3. Display specified student’s formatted Mark sheet
  4. Delete Student Entry
  5. Modify the Student info
  6. Exit

Note: use array of objects and read appropriate value on choice. 

Define a class baby with   the following attributes.

  1. name
  2. date of birth
  3. date on which beg  injection has to be given (60 days from date of birth)
  4. date on which polio drops is to be given (45 days from date of birth)

Write a constructor to construct the babyobjecty. The constructor must find out bcg and polio drops dates from the date of birth. In the main program define a baby and display its details.

Write a java program to take an integer thru command line argument and print the integer division of them. Catch Arithmetic Exception, NumberFormatException, ArrayIndexOutOfBoundsException, and General Exception.
Write an Application program to generate Employee Payslip.Create following classes.Employee-  emp_no,emp_name,basic ,DesInvalidBasicException- Class for user defined Exception (if basic is negative or non numeric).Payslip- do all additions (da, hra) And   deductions (loan_ins , gpr)If basic<=5000Then hra=5% of basic and da=3% of basic.

If basic>=15000

Then hra=7.5% of basic and  da=5% of basic

else

hra=10% of basic and da=8% of basic.

Based on that calculate netpay for each employee in Payslip class and generate the formatted pay slip.

Note: emp_no should be generated automatically with prefix EMP,

use array of objects.  

Write a java program to create a new exception NegativeNumberException. Throw the exception in the main method when a number taken thru command line is negative. Display appropriate message for the exception.
Write a simple java program that will catch exception using multiple catch.
Write a java program to print Purchase and Sales as follows:-print all the quarterly purchase and sales.-print the months in which sales were 6000 or more.-Print the total average purchase made during the year.-Print the total average sales made during the year.-Print the months in which highest purchase and sales were made.Take the data from user at runtime.
Write a java program to create an interface named Shape, which defines two methods public float area and public float perimeter. Create two classes named Rectangle and Circle which implements the interface Shape.
Create a class called Time having data member hh, mm,ss. Write an Application program that will add the data of two objects and store the answer in third object and display .
Write a java program to write particular string in a file, accept name as first argument of command line and string to be written as second argument of command line.
Write a java program to take data from file and print the data on the screen.
Write a java program to accept a java file from user at runtime and count the occurrences of java separator (java separator include (),{},[], semicolon, comma and dot operator)
Write a java program to transfer data from one file to another.
Write an application program that read the contents of one file and copy it to the other file. (DataInputStream and DataOutputStream class).
Write a java program to demonstrate PushbackInputStream class.
Write a java program to read the data from file using Random File Access. Replace the character ‘-‘ at the places where characters are in uppercase.
Write a java program to read and write object on the hard-disk.
Write program to demonstrate the file operation.
Write an applet program that will display a message “hello world”.
Write an applet program to handle mouse event that will display a message “JAVA” on mouse motion with (x,y) position of pointer.
Write an applet program to display three buttons and depending on the button clicked, the message should be displayed on status bar
Write an applet program to display three buttons labeled Red, Green, and Blue. Depending on the button clicked the background color of an applet should change
Write an applet program to display three checkboxes labeled Red, Green and Blue. Depending on the state of checkboxes background should change its color.
Write an applet program to display three radio buttons labeled Red, Green and Blue. Depending on the state of radio buttons background should change its color
Write an applet program to display four scrollbars on the four sides of applet all the scrollbars should have min value 1 and max value 100. The program should display the thumb position of the scrollbar on the applet.
Write an applet program to display three scroll bars at the left right and bottom position of an applet the minimum value and max value for each scroll bar is 0 and 255 respectively. The default value for all scroll bars will be 255. Program should change the background color of an applet depending on the thumb position of each scroll bar.
Write An Applet Program To Do Calculation Based On Selected Operator From Choice Using ActionListener.
Write an applet program to display1) label with text “Entered the data”2) textbox2) button with label add3) button with label delete.4) listIf user selects add button then non empty text from the textbox should be added to list box. If user selects delete button multi-select data from the list should be deleted.
Write an applet program for creating following controls:1. Four Textboxes for storing empno, empname, address and pincode2. Two Choice Controls for storing City and States3. Two Radio Buttons For Displaying gender information4. Three check boxes for displaying area of interesta. Computersb.Science

c.Arts

5. One TextArea

6. A Button labeled “Store” to transfer the data from all the controls

to the textarea in an appropriate format.

Write An Applet Program That Accept Date And Display It.
Write an applet that displays “Good Morning” if the current time is between 12 a.m. and 12 p.m.,”Good Afternoon” if the current time is between 12 p.m. and 6 p.m., and “Good Evening” if the current time is between 6 p.m. and 12 a.m.
Write An Applet Program To Create Registration Form For Your Mail Account And Register It.
Write An Applet Program That Append User Entered Text In The Text Box.
Write an Applet program to convert money for the local currency (selected Country) into U.S. Dollar.
Develop an applet that performs the following operations:

  1. when button is pressed, the word “down” is displays the current coordinates of the mouse
  2. when button is released, the word “up” is displays the current coordinates of the mouse

c.   when button is clicked, the message is “mouse is clicked” is shown .

Write An Applet Program Change The Background Color Of Canvas Using Itemlistener.
Write An Applet Program To Write User Note On Canvas.
Write An Applet Program To Copy Selected Option Value In To Textfield.
Write a java program to create a window with the following:

  1. a check box group to select the sex of the candidate.
  2.  a check box group to select the  marital status.

When we select in these groups the fact must reflect in the bio data displayed.

Write An Applet program to append all controls contents into TextArea.
Write An Applet program to copy the content of TextField into TextArea Using KeyListener.
Write applet that creates a thread that scrolls the message contained in message from right to left across the applet’s window.
Write an applet program to draw the circle of infinitely small radius where mouse is clicked.
Program to create a class Class1 in package pack2 which is inside pack1. Create main class ClassMain in package pack1 which instantiate Class1.
Program to create a class Class1 in package pack2 which is inside pack1. Create another class Class2 in package pack4 which is in pack3 and inheriting class Class1.
Program to create simple thread by extending Thread class.
Program to create and run simple thread by implementing Runnable interface.
Write a multi-threaded program using priority and join methods.
There are 5 clerks in an office, the speed of the clerks are in the ratio 2:1:3:5:4. The numbers of files allocated to each clerk are 10, 15, 6, 3 and 5 respectively. Write a multi-threaded java program to simulate this situation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s