CS3381 SET3
CS3381 SET3
Third Semester
(Regulations 2021)
1. Write a Java program to read 5 subject marks of a student and calculate the total and
grade. The grade system is as follows.
2. a. Define a class named COMPNUM for representing complex numbers that contains
necessary data members and member functions. A complex number has the general
form a + ib, where a is the real part and b is the imaginary part (i stands for imaginary).
Include methods for all the four basic arithmetic operators.
3. 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.
Page 1 of 4
4. 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
5. Define an interface “Queue Operations” which declares methods for a static queue.
Define a class “MyQueue” which contains an array and front and rear as data members
and implements the above interface. Initialize the queue using a constructor. Write the
code to perform operations on a queue object.
6. 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 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.
7. Develop a java program to find a smallest number in the given array by creating a one
dimensional array and two dimensional array using new operator
• Sequential Search
• Binary Search
Input elements : 37, 23, 0, 17, 12, 72, 31, 46, 100, 88, 54
10. Write a java application program for generating four threads to perform the following
operations
Page 2 of 4
11. Write a java program for exception handling:
a. To create a user defined exception whenever user input the word “hello”.
b. To add two integers and raise exception when any other character except
number (0 – 9) is given as input.
12. Create a class Doctor with attributes id, name, age and department. Initialize values
through parameterized constructor. If age of Doctor is not in between 25 and 65 then
generate user-defined exception “Age Not Within Range Exception”. If name contains
numbers or special symbols raise exception “Name Not Valid Exception”. Define the
two exception classes.
13. a. Write a program to replace all “word1” by “word2” from a file 1 and output is written to
file 2 and display the number of replacement.
b. Write a program to replace all “word1” by “word2” to a file without using temporary file
and display the number of replacement.
14. Write a Java program ‘WordCount’ that counts the words in one or more files. Start a
new thread for each file. For example, if you call
15. Using generic classes, write a program to perform the following operations on an array
16. Write a program TestThreadMany.java that takes a positive integer n from the
command line and creates exactly n threads that print out their own name. Here is a
sample execution:
$ java TestThreadMany 4
Hello, I am Thread #1
Hello, I am Thread #2
Hello, I am Thread #3
Hello, I am Thread #4
Page 3 of 4
17. a. Write a Java program to demonstrate that as a high-priority thread executes, it will
delay the execution of all lower-priority threads.
b. Write a Java program to read from an input file and convert the words to lower case
and write it in another file.
18. Write java programs that include generic method to satisfy the following property.
19. Write a JavaFX program to display the mouse position in the form of (x, y) co-ordinates
hen the text present on the screen is dragged somewhere else.
20. Write a JavaFX application for creating a Course Registration login form
Page 4 of 4