List of JAVA Programme
1. Create a “Hello, World” program that simply prints out that statement.
2. Write a program that prints three arguments taken from the command line.
3. Write a program that prints values from 1 to 100.
4. Create a class with a default constructor (one that takes no arguments) that prints a message. Create an object of this class.
5. Write Java assignment statements to evaluate the following equations:
(i) Energy = mass(acceleration*height+(velocity)sqr(2)/2)
(ii) Torque = 2m1m2/m1+m2 * g
6. Design and write a Java program to define a class called Rectangle that contains members for representing its length and breadth. Provide members to get and set these attributes.
7. Design a class to represent a bank account. Include the following members:
Name of the depositor
Type of account
Balance amount in the account
To assign initial values
To deposit an amount
To withdraw an amount after checking balance
To display the name and balance
8. Write simple program to calculate the sum of digits of any number.
9. Write a simple program to display a “*” I triangle shape.
Output will be like this
* * *
* * * * *
10. Write a simple program to call a method called simple from a main function. The method simple should accept an integer as an argument and calculate the square of the number in the method simple.
11. Write a Java program to add two integers and two float numbers. When no arguments are supplied, give a default value to calculate the sum. Use method overloading to achieve this.
12. Write a program to perform mathematical operations. Create a class called AddSub with methods to add and subtract. Create another class called MultDiv that extends from AddSub class to use the member data of the superclass. MultDiv should have methods to multiply and divide. A main method should access the method and perform the mathematical operations.
13. Write an interface with a method called display. Implement this method I a class to display two names.
14. Write an interface that has two methods called push and pop of a stack. Write a class to implement the two methods for a fixed size stack creation.
15. Write a small program to catch NegativeArraySizeException. This exception is caused when the array is initialized to negative values.
16. Write a program to handle NullPointerException and use the finally clause to display a message to the user.
17. Write a Java program that takes a string and converts it into uppercase and lowercase letters.
18. Write a Java program to find the volume of a sphere and a cone.
19. Write a Java program to convert rupees to dollars.
20. Write a Java program to find x to the power y. Use overloading for different cases when x and y are combinations of integer and floating point numbers.
21. Create an abstract class called Figure that has an abstract method called draw (). Make the subclasses called Filled_Rectangle, Filled_Arc and override the draw method in which you would print the message regarding the current object.
22. Write a Java program that has integer variables a, b, c and result as float. Store some values in them and apply the formula result = a/(b-c). Catch the probable exception.
23. Write a Java program that accepts two strings as command line arguments. It checks for the number of command line arguments. If they are less or more it throws an exception giving an appropriate message.
24. Write applets to draw the following shapes:
(iv) Square inside a circle
(v) Circle inside a square
25. Write an applet to display the following figure:
26. Write an applet to display a face.
27. Write an applet to display five buttons.
28. Write an applet to illustrate BorderLayout.
29. Write a Java program to create 5 threads by extending Thread class.
30. Write a Java program to create 5 threads by implementing Runnable interface.