0% found this document useful (0 votes)
14 views2 pages

Java - Imp Programs

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
14 views2 pages

Java - Imp Programs

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 2

JAVA PROGRAMMING IMP PROGRAMS

1) Define a class student with an int id and string name as data members and a method void SetData ( ).
Accept and display the data for five students.
2) Write a program to count the number of words from a text file using stream classes.
3) Write a Java program to copy content from one file to another file.
4) Write a program to create two threads. One thread will display the numbers from 1 to 50 (ascending order)
and another thread will display numbers from 50 to 1 (descending order).
5) Write a program to input the name and salary of the employee and throw user defined exceptions if the
entered salary is negative.
6) Define a class circle having data members Pi and radius. Initialize and display values of data members also
calculate the area of the circle and display it.
7) Write a program to create a vector with five elements as (5, 15, 25, 35, 45). Insert new element at 2nd
position. Remove 1st and 4th element from the vector.
8) Write a program to create two threads one thread will print even no. between 1 to 50 and other will print odd
numbers between 1 to 50.
9) Write a program to perform the following task. (i) Create a text file and store data in it. (ii) Count the number
of lines and words in that file.
10) Write a Java program to find out the even numbers from 1 to 100 using a for loop.
11) Write a java program to sort an 1-D array in ascending order using bubble-sort.
12) Write a Java program in which thread A will display the even numbers between 1 to 50 and thread B will
display the odd numbers between 1 to 50. After 3 iterations thread A should go to sleep for 500 ms.
13) Write a program to check whether the given number is prime or not.
14) Define a class employee with data members ‘empid’, ‘name’ and ‘salary’. Accept data for three objects and
display it.
15) Write a program to read a file (Use character stream)
16) Write a program to find the reverse of a number.
17) Write a program to add 2 integers, 2 strings and 2 float values in a vector. Remove the element specified
by the user and display the list.
18) Develop a program to create a class ‘Book’ having data members ‘author’, ‘title’ and ‘price’. Derive a class
‘BookInfo’ having a data member ‘stock position’ and method to initialize and display the information for
three objects.
19) Write a program to create a class ‘salary’ with data members ‘empid’, ‘name’ and ‘basicsalary’. Write an
interface ‘Allowance’ which stores rates of calculation for da as 90% of basic salary, hra as 10% of basic
salary and pf as 8.33% of basic salary. Include a method to calculate net salary and display it.
20) Write a program to check whether the string provided by the user is palindrome or not.
21) Design an applet to perform all arithmetic operations and display the result by using labels. textboxes and
buttons
22) Explain how to pass parameters to an applet? Write an applet to accept username in the form of parameter
and print “Hello ”.
23) Write a java applet to display the following output in Red color.

24) Write a Java applet to draw a bar chart for the following values.
25) Write a program to display ASCII value of a number 9.
26) Write a program to sort the elements of an array in ascending order.
27) Write a program to read a file and then count the number of words.
28) Write a program which displays functioning of ATM machine, (Hint : Withdraw, Deposit, Check Balance and
Exit)
29) Write a program to show the use of a copy constructor.
30) Write a program to show the Hierarchical inheritance.
31) Write a program to append content of one file into another file.
32) Develop and Interest Interface which contains Simple Interest and Compound Interest methods and static
final field of rate 25%. Write a class to implement those methods.
33) Write a program that throws an exception called “NoMatchException” when a string is not equal to “India”.
34) Write a program to print the sum, difference and product of two complex numbers by creating a class
named “Complex” with separate methods for each operation whose real and imaginary parts are entered
by user.
35) Write a program to draw a chessboard in Java Applet.
36) Write a program to create a user defined exception in java.
37) Write a program for reading and writing characters to and from the given files using character stream
classes.
38) Write a program to print all the Armstrong numbers from 0 to 999.
39) Write an applet program for the following graphics method. i) Drawoval ( ) ii) Drawline ( )
40) Write a program to copy all elements of one array into another array.
41) Write a program to implement the following inheritance :

42) Write a program to print even and odd numbers using two threads with a delay of 1000ms after each
number.
43) Write a program to generate the following output using the drawline ( ) method.

You might also like