-
Create a class called Time, which has three private instance variables โ hour, min and sec. It contains a method called add ( ) which takes one Time object as parameter and print the added value of the calling Time object and passes Time object. In the main method, declare two Time objects and assign values using constructor and call the add ( ) method.
-
Create a class Stack that declares a stack and the methods to perform push ( ), pop ( ) and checkEmpty ( ) operations on the stack. Create two stacks and write a menu-driven program to perform operations on the two stacks. Whenever the number of elements in the two stacks becomes equal, a message should automatically be generated displaying the number of elements in each stack.
-
Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the super class of the hierarchy. The instance variables of Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral. Write a program that instantiates objects of your classes and out.
- Write a program to check whether an array list contains an element or not.
- Write a program to check whether set contains an element or not.
- Write a program to traverse HashSet.
- Write a program to traverse Tree Set. 5.Write a program to calculate occurrences of each element of an array list.
- Write a program to find the Pair from an array list whose sum will be K, where K will be taken as input.
- Write a program to calculate frequency/occurrences of each element of an array.
- Write a program which will take a number as input. If number is prime and odd, then it will throw Custom Exception with proper message Number is invalid.
- Write a program calculate frequency/occurrences of each element of an array and then sort by value and then print it.