Set 1
Set 1
1. Write a java program to create an interface named Shape that contains two integers and an empty
method named printArea (). Provide three classes named Rectangle, Triangle and Circle such that each
one of the classes implements the class Shape. Each one of the classes contains only the method
printArea () that prints the area of the given shape
2. Write a Java Program to create a user defined package for three classes Add, Sub, Mul.
3. Write a Java Program to find Math.pow(n,p). - If either n or p is negative, then the method must throw
an exception which says "n or p should not be negative.". - If both n and p are zero, then the method
must throw an exception which says "n and p should not be zero."
4. Write a Java Program to count number of invalid entries. Example: java example 5 2 a 1 b => Invalid =
2
10. Write a Java program that reads a file and prints its content in reverse order.
11. Write a java program that displays the number of characters, lines and words in a text file.
12. Write a Java program that implements a multi-thread application that has three threads. First thread
generates random integer and displays “Good Morning” every one second, if the value is even, second
thread computes and prints “Hello” and If the value is odd, the third thread will print “Welcome”.
13. Write a Java program that implements a multi-thread application that has three threads. First thread
generates random integer every 1second and if the value is in between 1 to 100 , second thread computes
and prints Good. If the value is in between 101 to 200 , the third thread will print Morning.
14. Write a Java program to perform the following on LinkedList
Create a doubly linked list of elements.
Delete a given element from the above list.
Display the contents of the list after deletion.
15. Develop JDBC Application for user login and check whether user details are valid of not.
Name Passwor
d
Raju 123
Ramesh 789
Somesh 456
Sanjeev 345
Swathi 496