Professional Documents
Culture Documents
Faculty-In-
Charge: : Dr. N. Balaji Slot:
1. Consider an integer array, the number of elements in which is determined by the user. The elements
are also taken as input from the user. Write a program to find those pair of elements that has the
maximum and minimum difference among all element pairs.
3. Create an abstract class 'Animals' with two abstract methods 'cats' and 'dogs'. Now create a class
'Cats' with a method 'cats' which prints "Cats meow" and a class 'Dogs' with a method 'dogs' which prints
"Dogs bark", both inheriting the class 'Animals'. Now create an object for each of the subclasses and call
their respective methods.
4. Write a Java program to append the specified element to the end of a linked list.
5. Write a Java program to get the first and last occurrence of the specified elements in a linked list.
6. Write a Java program to store text file content line by line in an array.
8. Write a Java program to create an abstract class GeometricShape with abstract methods area()
and perimeter(). Create subclasses Triangle and Square that extend the GeometricShape class and
implement the respective methods to calculate the area and perimeter of each shape.
9. Write a Java program that reads a list of integers from the user and throws an exception if any
numbers are duplicates. (User Defined Exception)
10. Write a Java program to find the longest Palindromic Substring within a string.
Sample Output:
The given string is: thequickbrownfoxxofnworbquickthe
The longest palindrome substring in the given string is: brownfoxxofnworb
The length of the palindromic substring is: 16