OOPJ
OOPJ
Practical File
Submitted By
Himani Gupta
CSE-AI 1
JAVA practice
06701172023
Submitted to
Mr. Rahul Sachdeva
Assistant Professor
Dept. of AI & DS
5. Application 1. Create a calendar, enter date to get its previous date, next date and days
Program 2. Use 2D array to print matrix, perform addition and multiplication on it
with another matrix.
8. Inheritance 1. Create class addTime that can add two times in hr, min, sec
2. Create a base class account having acc number, acc type, name of
holder, read(), print().Derive this class into savings and current acc
class where savings acc has interest rate 10%, update balance; and
current acc has maximum number of transactions. If the number of
transactions >30, deduct 1500. Create 10 objects, 5 of savings type and
5 of current type
3. Create a class to read and print details of students. Also create a
function to get average, minimum and maximum marks.
9. Interfaces 1. Design an interface with a method reverse that reverses the digits of a
number
2. Design an interface having method to get velocity with parameter r that
calculates and returns velocity of a satellite given by the formula
velocity=root mu/r where r is the altitude of satellite taken from the
earth and mu is Kepler’s constant with value 3.986004418* (10**5).
Create a nested interface with a method to get acceleration with
parameter r that calculates and returns the acceleration of the satellite
given by the formula mu/(r**2)
3. Write a program having a mean interface. Create a method mean that
calculates the mean of user entered numbers arranged in an array.
Extend the interface having method deviation that calculates the
(absolute) deviation from the mean value for each of the numbers in the
array.
4. Write a program in which 3 interfaces I1 I2 I3 are defined, I2 extends
I1, I3 extends I1 and I2. I1 declares a method withdraw, I2 declares a
method deposit, I3 declares a display that shows balance of account
number. Create a class with var acc number, name, address, balance
that implements the interfaces
10. File Handling-1 1. Write a program that calculates the area of a room and the cost of white
washing, include provision for window on any of the walls. The
parameters for the room length height width are taken from the user. If
there is a window then its length and width are taken from the user. In
any case of parameter, if input is less than 1 then throw an invalid
dimension exception; otherwise calculate and display area and cost of
white washing
2. Write a program that reads data for name class roll number marks of a
student and print them to a file. Also read details from the file and
show on the monitor
3. Write a program to copy contents of one file into another
11. File Handling-2 1. Write a program to check whether the contents in two files is same or
not
2. Write a program to count the number of digits stored in the file
3. Write a program to write a string character by character to a file and
read the string character by character from the file, print it on the screen
4. Read the data from the keyboard using buffered reader class
12. Application 1. Create a class with members name, roll number, stream, marks, write it
Program in a file for 10 students such that when you enter roll number, only the
details of that student are printed.
EXPERIMENT-1
Program 1:
Write a program to multiply two floating point numbers
System.out.println("Before swapping:");
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
System.out.println("\nAfter swapping:");
System.out.println("num1 = " + num1);
System.out.println("num2 = " + num2);
}
}
Program 3:
Write a program to add two binary strings
int i = binary1.length() - 1;
int j = binary2.length() - 1;