Java Programms

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Mr. Bhandare P.S.

JAVA Program List


Chapter 1: Introduction to java
1. Write a program to compute sum of digits of number.
2. WAP to reverse the entered number.
3. WAP to find factorial of number.
4. WAP to find factorial of number using recursion.
5. WAP to generate Fibonacci’s series up to 10 numbers.
6. WAP to check whether entered number is even or odd.
7. WAP to check whether entered number is prime or not.
8. WAP to check whether entered number is Armstrong or not.
9. WAP to check whether entered number is palindrome or not.
10.WAP a program to calculate percentage for 4 subject & decide grade from
percentage.
11.WAP to input a number & find sum of all prime numbers from 1 to that
number.
12.WAP to check whether entered number if divisible by 5 or not.
13.WAP to print all the number from 100 to 200 divisible by 7.
14.WAP to demonstrate use of mathematical functions.
15.Write a program to display following output?
* * * * *
* * * *
* * *
* *
*
16.WAP to print all ASCHII character.
17.Write a simple Java program using bitwise operator.
18.Input two integer values from keyboard and swap their contents without
using any other temporary variable.
19.Read the price of an item (rupees) in float and display number of paise.
20.Convert the Celsius temperature input from keyboard into its Fahrenheit
equivalent using following formula: C = (F – 32) /1.8
21.Accept the value of money in rupees and convert it into dollars.
22.Find squares of all the numbers from 1 to n.
23.Input a long number from keyboard and count total number of even digits in
it.
Mr. Bhandare P.S.

//Experiment Programs
24.Develop a program to display name of players who played more test
matches.Given: Names and No. of test matches played of three players.
25.Develop a program to do the addition of two numbers if both are greater
than 10.
26.Develop a program to print the multiples of 5 between 20 to 70.
27.Develop a program to print 7 terms of the Fibbonacci series.
28.Develop a program to find names of those companies which have more than
10000 employees. Given:Names and No. of employees of four companies.

Chapter 2: Classes, Objects & Methods.


1. Write a program to add 2 integer, 2 string and 2 float objects to a vector.
Remove element specified by user and display the list. (8m)
2. Write a program to accept two numbers as command line arguments and
print the addition of those numbers. (4M).
3. Create a class ‘Rectangle’ that contains ‘length’ and ‘width’ as data
members. From this class derive class box which has additional data
member ‘depth’. Class ‘Rectangle’ consists of a constructor and an area ( )
function. The derived ‘Box’ class have a constructor and override function
named area ( ) which returns surface area of ‘Box’ and a volume ( ) function.
Write a java program calling all the member function. (6m)
4. Write a program to create a class Account having variable accno, accname
and balance. Define deposite ( ) and withdraw ( ) methods. Create one object
of class and perform the operation.(8M)
5. Perform following string / string buffer operations, write java program. (4
M)
(i) Accept a password from user
(ii) Check if password is correct then display “Good”, else display
“Wrong”
(iii) Display the password in reverse order.
(iv) Append password with “welcome”.
Mr. Bhandare P.S.

6. Write a program to implement a vector class and its method for adding and
removing elements. After remove display remaining list. (4m)
7. Define a class Item having data member code and price. Accept data for one
object and display it.(4M)
8. Write a program to create a vector with seven elements as (10, 30, 50, 20,
40, 10, 20). Remove element at 3rd and 4th position. Insert new element at
3rd position. Display the original and current size of the vector. (8m)
9. Write a program to accept a number as command line argument and print the
number is even or odd. (4m)
10.Write a program to implement following inheritance : (4M)

a.
11.WAP to define class student having data members roll no & name. Derive a
class attendance with data member as present days. Write a method to
calculate & print average attendance assuming total days as 180.
12.Define a class Item having data members code & price. Accept the data for
five objects & display data in tabular form using array of objects. Also
display total price of all item.
13.WAP to check whether given string is palindrome or not.
14.Define a class employee with data members as emp_id and salary. Accept
data for 5 objects and print it.
15.WAP to accept a number from user & convert it into binary, Hexadecimal
and octal format & print it.
16.Write a program which will read string and rewrite it in the alphabetical
order for example the word “Java” should be written as “aaJv”.(Ignore the
case of the letter).
17.Write a program in Java to read 10 strings from console and then print the
stored strings on console. (Use String Class).
18.Write a program to demonstrates the following.
(i) To convert lower case string to upper case
(ii) To calculate the length of given string
(iii) To compare two strings
Mr. Bhandare P.S.

19.Accept an array of 10 floats from user and find the largest number among
them.
20.Input a number from command line and find its binary, octal and
hexadecimal equivalent.
21.Count numbers of vowels in the StringBuffer.
22.Accept first name, middle name and surname from keyboard and display the
while in sequence as a single string.
23.Display the string in reverse order.
24.Accept any string containing all types of characters and symbols from user
and count only number of digits.
25.Sort the characters of the string inputted from user.
26.Accept marks and roll no of 10 students from user and display roll number
of student having highest marks.
27.Input a string from user and invert the case of each character of the string.
E.g. Input: “RaJaN” output: “rAjAn”.
28.Implement a stack using vector. Implement all basic operations on vector.
29.Implement a queue using vector. Simulate insert and delete operations.
30.Perform multiplication on two different 3 X 3 matrices.
31.WAP to sort the array elements.
32.WAP to search element in unsorted array
33.WAP to Insert element into array.
34.WAP to delete element from array.
35.WAP to add two 3x3 matrices.
36.WAP to Subtract two 3x3 matrices.
37.WAP to transpose a matrix.
//Experiment Programs
38.Define a class ‘Mobile’ with data members ‘company_name’ &
‘screen_size’.Initialize and display values of data members for 5 mobiles
using array of objects.
39.Define a class ‘Cube’ with data members length,breadth and height.
Initialize three objects using different constructors and display its volume.
40.WAP to find all substrings of a string and print them. For example
substrings of ‘fun’ are:- ’f’, ‘fu’,’fun’, ‘u’, ‘un’ and ‘n’. Use substring
method of String class to find substring.
41.Implement a program to accomplish the following task using String and
StringBuffer class:
Mr. Bhandare P.S.

-To search a word inside a string


-To search the last position of a substring.
-To compare two strings.
-To print reverse of string.
42.WAP to implement a vector that accepts five elements from command line
and store them in vector and display the objects stored in a vector.
43.Implement a program to accomplish the following task using Vector class:
i.To add two integers,two float,two characters,two string objects.
ii.To search a particular object of the vector.
iii.To display all objects along with their index position.(for eg. Character
‘A’ is present at position 4 in vector).
iv.To delete all objects from vector.
44.Develop a program to create a class ‘Book’ having data members
‘author’,’title’ & ‘publisher’. Develop a class ‘BookInfo’ having data
members ‘price’,’stock position’ and a method ‘show()’.Initialize and
display the information for 3 objects of ‘BookInfo’.
45.Develop a program to create a class ‘Bird’ having data members ‘catagory’
and a method ‘show()’.Derive a class ‘Parrot’ with data members
‘no_of_parrots’ and method ‘show()’.Initialize using constructor and
display the information.
46.Develop a program to create a class ‘Fruits’ having data members
‘countable’(values=Yes/No ) & a method ‘display()’. Develop a class
‘Watermelon’ having data members ‘price’,’quantity’ and a method
‘show()’.Initialize and display the information for 3 objects of
‘Watermelon’.
Chapter 3: Packages & interfaces
1. Write a program to implement following hierarchy:

a.
Mr. Bhandare P.S.

2. Define a class ‘Employee’ having data members name and basic-salary.


Also declare an interface ‘Gross’ having method to calculate gross salary.
Derive a class ‘Salary’ using class ‘Employee’ and interface ‘Gross’ and
display the name, basic-salary and gross-salary.
3. Design a package containing a class which defines a method to find area of
rectangle. Import it in Java application to calculate area of a rectangle.
4. Implement the inheritance given below by assuming suitable methods.

a.
5. Design a package containing a class which defines a method for arithmetic
operations. Import it in Java application and perform the operations.
6. Define a package named ‘useFul’ with a calss names ‘UseMe’ having
following methods:
1)area()- To calculate the area of given shape.
2)salary()- To calculate the salary given basic Salary,da,hRA.
3)percentage()-To calculate the percentage given total marks and marks
obtained.
4)Develop a program named ‘Package Use’ to import the above package
‘useFul’ and use the method area().
5) Develop a program named ‘manager’
Chapter 4: Exception Handling & Multithreaded Programming
1. Write a program to define, instantiate and start new thread using
java.lang.Runnable.
2. Write a program to create two threads so one thread will print ascending
numbers whereas second thread will print descending numbers between
sequence 1 to 15 numbers.
3. What is exception? WAP to accept a password from the user and throw
“Authentication Failure” exception if the password is incorrect. (8M)(S-17)
4. Write a program to create two threads, one to print numbers in original order
and other in reverse order from 1 to 10. (8M) (S-17)
Mr. Bhandare P.S.

5. Write a thread program for implementing the ‘Runnable interface’. (8M)(W-


16)
6. Define an exception called ‘No match Exception’ that is thrown when a
string is not equal to “MSBTE”. Write program. (8M) (W-16)
7. Write a program to input name and age of person and throws user defined
exception, if entered age is negative .(8M) (S-16) (S-15)
8. Write a program to accept password from user and throw ‘Authentication
failure’ exception if password is incorrect.(8M)(W-15)
9. Write a program to create two threads ; one to print numbers in original
order and other to reverse order from 1 to 50.(8M) (W-14)
10.Create a user-defined exception “EvenNumberException” if the number
inputted in an even.
11.Accept a string from user and throw the exception if that string does not start
with a capital letter.
12.Input the password and login name from command line and throw an
exception if it does not match with our previously stored values.
13.Accept two numbers from user perform any arithmetic operation on them
and throw an exception when result is negative.
14.Accept a number from user and throw an exception if that number is prime
then throw “PrimeNumberException”.
15.Display seconds using one thread and minutes using another thread.
16.Accept two strings from user and throw a “NoCaseMatchException” when
case is not matching and throw “NotEqualsException” when strings are not
equal.

Chapter 5: Java Applets & Graphics Programming.


1. Write a program to create an independent window with window title as
“Welcome to Java”.
2. Write a simple applet to draw a rectangle which is filled with Red color.
3. Write an applet program that accept input from a HTML <Param> tag to
display the logo of Olympic. All the circle are of same radius, assume the
radius.
4. Write applets to draw a square inside the circle.
5. Write a applet program to display “Polygons”.
6. Write a simple applet to draw rectangle which is filled with red color.
7. Create an applet with size 300 X 200 and display “Hello” on it at the center.
Mr. Bhandare P.S.

8. Display the numbers from 1 to 10 reversely on the applet.


9. Display a pentagon on the applet filled with green color.
10.Create an applet to display the string “Applet Graphics Programming” with
font “Courier New”, size: 15 points and BOLD + ITALIC.
11.Display different concentric oval shapes on the applet at the center with
different colors.
12.Create an applet with blue background, yellow foreground and display string
“Core Java Programming” with Arial font point size = 20.
13.Accept a date using <param> tag and display along with the message, “My
Birthday is: “.
14.Accept the flower name as parameter and display it along with the message
“It is a beautiful flower”. The HTML file should be placed in the directory
called flower. The background color of this applet is light gray. The text
displayed in Times new roman with 40 points.
15.Input two strings from <param> tag concatenate them and display them in
the status window.
16.Create an applet with background color red and draw a circle at the middle
of applet which if filled with blue color.

Chapter 6: File I/O & collection frame work

1. Write a program that will count no. of characters in a file.(4M)(w-16)


2. Write a java program to copy contents of one file to another file.(4M)(w-16)
3. Write a program to copy contents of one file to another file using character
stream class.(4M)(s-15)
4. WAP to Create New File using Java Program.
5. WAP to Get File Length (Size) and File Path in Java.
6. WAP to Write Content into File using FileOutputStream in Java.
7. WAP to Read Content from File using FileInputStream in Java
8. WAP to Write Content into File using BufferedWriter in Java.
9. WAP to Read Content from file using BufferedReader in Java.
Mr. Bhandare P.S.

10.WAP to Delete File using Java Program.


11.WAP to Copy Files using Java Program

You might also like