0% found this document useful (0 votes)
19 views4 pages

CS3381 SET3

Uploaded by

sugimpt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
19 views4 pages

CS3381 SET3

Uploaded by

sugimpt
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 4

B.E / B.Tech.

PRACTICAL END SEMESTER EXAMINATIONS, NOVEMBER/DECEMBER 2022

Third Semester

CS3381 - OBJECT ORIENTED PROGRAMMING LABORATORY

(Regulations 2021)

Time : 3 Hours Answer any one Question Max. Marks 100

Aim / Principle / Program / Output & Viva-Voce Record Total


Procedure Drawing Results
20 30 30 10 10 100

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.

Letter Grade Grade Points Marks Range


O (Outstanding) 10 91 – 100
A+ (Excellent) 9 81 – 90
A (Very Good) 8 71 – 80
B+ (Good) 7 61 – 70
B (Average) 6 50 – 60
RA 0 < 50

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.

b. Write a Java program that determines the number of days in a month.

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

Create an interface “CreditCardInterface” with methods to view CreditAmount, viewPin,


8. changePin and payBalance. Create a class Customer (name, card number, pin,
creditAmount – initialized to 0). Implement methods of the interface “Credit Card
Interface” in Customer class. Create an array of customer objects and perform the
following actions.
• Pay Balance
• Change Pin

9. Write a Java program to implement

• 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

• Getting N numbers as input


• Printing the numbers divisible by five
• Printing prime numbers
• Computing the average

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

“java WordCount report.txt address.txt Homework.java “


then the program might print
address.txt: 1052
Homework.java: 445
report.txt: 2099

15. Using generic classes, write a program to perform the following operations on an array

i) Add an element in the beginning/middle/end


ii) Delete an element from a given position.

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.

a. To counts the number of odd integers in an integer list


b. To exchange the positions of two different elements in an array.
c. To find the maximal element in the range [begin, end] of a list.

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

You might also like