SET5 Notes
SET5 Notes
Third Semester
(Regulations 2021)
b) Create an outer class with a function display, again create another class
inside the outer class named inner with a function called display and call
the two functions in the main class.
2. Write a program to create a class named shape. In this class we have three
sub classes circle, triangle and square each class has two member function
named draw () and erase (). Create these using polymorphism concepts.
5. Create class Number with only one private instance variable as a double primitive type. To
include the following methods (include respective constructors) isZero( ), isPositive(),
isNegative( ), isOdd( ), isEven( ), isPrime(), isAmstrong() the above methods return boolean
primitive type. getFactorial(), getSqrt(), getSqr(), sumDigits(), getReverse() the above
methods return double primitive type. void listFactor(), void dispBinary().
Page 1 of 3
6. a) Write a program for example of try and catch block. In this check
whether the given array size is negative or not.
8. Develop a java application with an Employee class with Emp_name, Emp_id, Address,
Mail_id, Mobile_no as members. Inherit the classes, Programmer, Assistant Professor,
Associate Professor and Professor from employee class. Add Basic Pay (BP) as the
member of all the inherited classes with 97% of BP as DA, 10 % of BP as HRA, 12% of BP
as PF, 0.1% of BP for staff club funds. Generate pay slips for the employees with their
gross and net salary.
9. Write a Java Program to create an abstract class 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 extends the class Shape. Each one of the
classes contains only the method printArea( ) that prints the area of the given shape.
10. Create a multithreaded program by creating a subclass of Thread and then creating,
initializing, and staring two Thread objects from your class. The threads will execute
concurrently and display Java is hot, aromatic, and invigorating to the console window
11. Write a java program that implements a multi-threaded application that has three threads.
First thread generates a random integer every 1 second and if the value is even, the second
thread 69 computes the square of the number and prints. If the value is odd, the third thread
will print the value of the cube of the number.
12. Write a java program to find the maximum value from the given type of elements using a
generic function.
13. Develop the Internal mark calculation system based on the attendance percentage using
Java. Get the student name, register number, total number of working days in the semester
and Number of days present. Calculate attendance percentage of the students and award
attendance mark based on the following condition.
Page 2 of 3
Attendance percentage >=80 and < 90 – 4 Marks
15. Write a Java program to implement user defined exception handling. Display the result for
the following input a=1, b=0 perform c=a/b.
16. Write a java program that implements a sequential search and binary search.
17. Write a java program that implements an insertion sort and selection sort.
18. Write a Java program that reads a file and displays the contents of the file on the screen,
with a line number before each line.
19. Write a generic method to count the number of elements in a collection that have a specific
property (for example, odd integers, prime numbers, palindromes).
Page 3 of 3