Java Assignment 2024

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

JAVA ASSIGNMENT

1. 1
10
101
1010
10101
2 3 4 5 𝑛
2. 1 + 2! − 3! + 4! − 5! + ⋯ + 𝑛!

3. Write a program in java to accept a string and print it in reverse order and also check whether the
string is palindrome or not.
4. Design a class to represent bank account with following members:
To initialize data to display all information of an object of bank account class. Write a program
to test above class.

5. Design a class name Showroom with the following description:


Instance variables/ Data members:
String name – To store the name of the customer long mobno –
To store the mobile number of the customer double cost – To
store the cost of the items purchased double dis – To store the
discount amount
double amount – To store the amount to be paid after discount
Member methods: –
ShowRoom() – default constructor to initialize data members void input()
– To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on following criteria
Cost Discount
Less than or equal to ₹ 10000 5%
More than ₹ 10000 and less than or equal to ₹ 20000 10%

More than ₹ 20000 and less than or equal to ₹ 35000 15%

More than ₹ 35000 20%

6. Implement method overloading to calculate the area of 2D shape.


7. Write a program to override volume () of different 3D shapes assume necessary hierarchy.
8. Demonstrate ‘multiple’ inheritance in java with a program.
9. Write a program to implement the stack using push & pop methods.
10. Write a user defined program to show how package works.
11. Write a java program showing all different types of exception handling mechanism in java. [try-
catch,throw,throws,finally]

12. Write a program in java to accept a string in lower case and change the first letter of every word to upper
case. Display the new string.

13. Write a program to extract a substring starting from nth position and ending at kth position from a
given string.

14. Write a program in java to display different priority values of a thread.

15. Write a program that prints two words “PING” and “PONG” in a multithreaded environment. A
delay of 3 sec should be created between those two words while printing.

16. Develop an applet that receives two numbers and display their GCD,LCM, MAXIMUM,
MINIMUM in text box. Write a program to test above applet.

17. Create a class called Matrix. It includes methods called “matMul” for multiplying two Matrix
objects and return the resultant Matrix object and “matAdd” for adding two Matrix objects and
return the resultant Matrix.

18. Write a program that accepts a list of seven items and store them in a vector. Include a method.
a to delete 2nd item.
b To insert an item at 3rd position.
c To print all elements of vector.
d To insert an element at last.

19. Write a program to create a text file to store name and address of different customers. Also include
a method to find address against a given name.

20. Write a program in java to test JDBC using oracle database.

You might also like