VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Name of the
M.Pranavi
Student
Roll Number 23071A6739
Name of the Lab OOPJ
Week No 1
1.Write a Java program to multiply two given matrices.
import java.util.Scanner;
import java.util.Arrays;
public class Matrix {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of rows in the first matrix: ");
int rows1 = scanner.nextInt();
System.out.print("Enter the number of columns in the first matrix: ");
int cols1 = scanner.nextInt();
System.out.print("Enter the number of rows in the second matrix: ");
int rows2 = scanner.nextInt();
System.out.print("Enter the number of columns in the second matrix: "); int cols2 = scanner.nextInt();
int[][] matrix1 = new int[rows1][cols1];
System.out.println("Enter elements of the first matrix:");
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols1; j++) {
matrix1[i][j] = scanner.nextInt();
}
}
1
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
int[][] matrix2 = new int[rows2][cols2];
System.out.println("Enter elements of the second matrix:");
for (int i = 0; i < rows2; i++) {
for (int j = 0; j < cols2; j++) {
matrix2[i][j] = scanner.nextInt();
}
}
int[][] result = new int[rows1][cols2];
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols2; j++) {
result[i][j] = 0;
for (int k = 0; k < cols1; k++) {
result[i][j] += matrix1[i][k] * matrix2[k][j];
} }}
System.out.println("Result of matrix multiplication:");
for (int i = 0; i < rows1; i++) {
for (int j = 0; j < cols2; j++) {
System.out.print(result[i][j] + ");
}
System.out.println();
}
}
}
2
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
2.Write a Java program to find prime numbers between 1 to n.
import java.util.Scanner;
class Prime{
public static void main(String[] args){
Scanner r1 = new Scanner(System.in);
int i;
System.out.println("Enter a number");
int n = r1.nextInt();
for(i=2;i<n;i++){
if(n%i==0)
{
System.out.println(n +" is not prime");
break;
}
else
System.out.println(n + " is prime");
break;
}
}
}
}
3
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
3.Write a Java program that prints all real solutions to the quadratic equation ax2+bx+c.
import java.util.Scanner;
public class Quadratic
{
public static void main(String[] Strings)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter the value of a: ");
double a = input.nextDouble();
System.out.print("Enter the value of b: ");
double b = input.nextDouble();
System.out.print("Enter the value of c: ");
double c = input.nextDouble();
double d= b * b - 4.0 * a * c;
if (d> 0.0)
{
double r1 = (-b + Math.pow(d, 0.5)) / (2.0 * a);
double r2 = (-b - Math.pow(d, 0.5)) / (2.0 * a);
System.out.println("The roots are " + r1 + " and " + r2);
}
else if (d == 0.0)
{
double r1 = -b / (2.0 * a);
System.out.println("The root is " + r1);
}
else
{
System.out.println("Roots are not real.");
}
}
}
4
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Name of the
M.Pranavi
Student
Roll Number 23071A6739
Name of the Lab OOPJ
Week No 2
a. Write Java program on use of inheritance, preventing inheritance using
final, abstract classes.
1.Use of Inheritance
class Employee{
float salary;
Employee(){
this.salary=50000;
}
}
class coder extends Employee{
float bonus;
coder(){
this.bonus =2000;
}
public static void main(String[] args){
Programmer pr= new Programmer();
float total=pr.gettotal (pr.salary, pr.bonus);
System.out.println("total"+total);
}
float gettotal(float bas, float bon){
return bas+bon;
}
}
OUTPUT:
2.preventing inheritance from final
File Edit Format View Help
final class Employee{
float salary;
Employee(){
this.salary=70000;
}
}
5
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
class Pro extends Employee{
float bonus;
Pro(){
this.bonus =2000;
}
public static void main(String[] args) {
Pro pr= new Pro();
float total-pr.gettotal (pr. salary, pr. bonus);
System.out.println("total"+total);
}
float gettotal (float bas, float bon){
return bas+bon;
}
OUTPUT:
3.abstract classes
File Edit Format View Help abstract class A{
}
abstract void wrt();
void rd(){
System.out.println("red");
class B extends A{
void wrt(){
System.out.println("hello world");
}
public static void main(String[] args) {
B b=new B();
b.wrt();
b.rd();
}
}
OUTPUT:
b. Write Java program on dynamic binding, differentiating method
overloading and overriding.
1.Dinamic binding
File Edit Format View Help
class One{
void hello(){
}
6
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
}
System.out.println("hello");
class Two extends One{
public static void main(String[] args) {
One obj = new Two();
//Dynamic Binding
obj.hello();
}
}
OUTPUT:
2.Differentiating method overriding
Override - Notepad
File Edit Format View Help
class Ride{
void one(){
}
}
System.out.println("gfxbtf");
class Override extends Ride{
void one(){
}
System.out.println("one");
public static void main(String[] args) {
Override obj = new Override();
obj.one();
}
}
OUTPUT:
3.Differentiation method overloading
File Edit Format View Help
class Overload{
void m(){
}
System.out.println("method1");
void m(String x){
}
System.out.println("method2 "+ x);
void m(String x, int y){
}
System.out.println("method3 "+ x + y);
public static void main(String[] args) {
7
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Overload obj = new Overload();
obj.m();
obj.m("hi"); obj.m("hi",9);
}
}
OUTPUT:
c. Develop a java application to implement currency converter (Dollar to INR.
EURO to INR, Yen) using Interface
OUTPUT:
Name of the
M.Pranavi
Student
8
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Roll Number 23071A6739
Name of the Lab OOPJ
Week No 3
a. Write a Java program to create a package named "com.mycompany.math"
that contains a class named "Calculator" with methods to add, subtract,
multiply and divide two numbers. Write a test program to use this
package.
package com.mycompany.math;
public class Calculator{ public void add(int a, int b) {
int c= a+b;
System.out.println("add "+ c);
}
public void subtract(int a, int b) {
int c= a-b;
System.out.println("subtract "+c);
}
public void multiply(int a,int b) {
int c= a*b;
System.out.println("multiplication "+c);
}
public void divide (int a, int b) {
int c= a/b;
System.out.println("division "+c);
}
}
Import com.mycompany.math.Calculator; class Test{
public static void main(String[] args) {
Calculator obj = new Calculator();
obj.add(3,5);
obj.subtract (10,4);
obj.multiply(5,10);
obj.divide (10,5);
}
}
b. Create a package named "com.mycompany.util" that contains a class
named "StringUtils" with a method named "reverseString" that takes a
string as input and returns the reverse of the input string. Write a test
program to use this package.
9
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Package com.mycompany.util;
public class Stringutils {
public string reverse(String st) { String x = "";
int le-st.length();
System.out.println("Length of the string: + le); for (int i = le 1; i >= 0; i--) {
-
x = x + st.charAt(i);
}
return x;
}
}
import java.util.Scanner;
com.mycompany.util.Stringutils;
import class Test{
public static void main(String[] args){
Scanner sc-new Scanner(System.in); System.out.println("Enter string ");
string s=sc.nextLine();
Stringutils obj=new Stringutils();
string a-obj.reverse(s);
System.out.println(a);
}
}
Name of the
M.Pranavi
Student
Roll Number 23071A6739
Name of the Lab OOPJ
10
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Week No 4
a. Write a Java program to implement user defined exception handling.
class InvalidAgeException extends Exception {
public InvalidAgeException(String str) {
}
}
super(str);
public class TestCustomException {
static void validate(int age) throws InvalidAgeException { if (age< 18) {
throw new InvalidAgeException("Age is not valid to vote"); } else {
}
System.out.println("Welcome to vote!");
public static void main(String[] args) {
try {
validate(13);
} catch (InvalidAgeException ex) {
System.out.println("Caught the exception");
System.out.println("Exception occurred: " + ex);
}
}
}
OUTPUT:
b. Write a Java program to throw an exception “Insufficient Funds” while
withdrawing the amount in the user account.
11
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
OUTPUT:
c. Write a Java program to implement Try-with Resources, Multi-catch
Exceptions, and Exception Propagation Concepts?
12
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
OUTPUT:
13
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
14
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Name of the
M.Pranavi
Student
Roll Number 23071A6739
Name of the Lab OOPJ
Week No 5
a. Write a java program to split a given text file into n parts. Name each part
as the name of the original file followed by .part where n is the sequence
number of the part file.
import java.io.*;
import java.util.Scanner;
public class cold{
public static void main(String[] args) throws IOException{
Scanner bhai =new Scanner(System.in);
System.out.println("enter file name without extension txt");
String x bhai.nextLine();
File f = new File("C:\\Users\\VNR\\Desktop\\test\\"+ x + ".txt");
System.out.println("enter n value");
int n= bhai.nextInt();
int siz= (int)(f.length());
int i,j,k; if(f.exists()){ if(siz< n) {
System.out.println("insufficient text");
}
else{
for(int m=1;m<=n;m++){
String fileName = x+m+ ".part.txt";
FileOutputStream gg = new FileOutputStream("C:\\Users\\VNR\\Desktop\\test\\
part\\"+ fileName);
}
FileInputStream r = new FileInputStream("C:\\Users\\VNR\\Desktop\\test\\"+ x +
".txt"); for(i=1;i<=n;i++){
String y= x + i + ".part.txt";
FileOutputStream oh = new FileOutputStream("C:\\Users\\VNR\\Desktop\\test\\
part\\"+ y);
if(i!= n) {
for(j=1;j<= (int)(siz/n);j++){
k=r.read(); oh.write((char)k);
}
}
else{
while((k=r.read())!=-1){ oh.write((char)k);
}
}
}
}
System.out.println("divided given file into " + n +"parts");
15
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
else
System.out.println("file doesn't exist");
}
}
OUTPUT:
b. Write a Java program that reads a file name from the user, displays
information about whether the tile exists, whether the file is readable, or
writable. The type of tile and the length of the file in bytes.
OUTPUT:
Name of the M.Pranavi
16
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
Student
Roll Number 23071A6739
Name of the Lab OOPJ
Week No 6
a. Write a Java program on Random Access File class to perform different
read and write operations.
17
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
OUTPUT:
b. Create a class called Employee with properties name(String), dateofbirth
(java.util.Date), department(String), designation(String) and Salary(double).
Create respective getter and setter methods and constructors (no-argument
constructor and parameterized constructor) for the same. Create an object of
the Employee class and save this object in a file called “data” using
serialization. Later using deserialization read this object and prints the
properties of this object.
18
VALLURUPALLI NAGESWARA RAO VIGNANA JYOTHI
INSTITUTE OF ENGINEERING AND TECHNOLOGY
An Autonomous, ISO 9001:2015 & QS I-Gauge Diamond Rated Institute, Acc redited by NAAC with ‘A++’ G rade
NBA Ac c reditation for B.Tec h. C E,EEE,ME,EC E,C SE,EIE,IT,AME, M.Tech. STRE, PE, AMS, SWE Programmes
Approved by AIC TE, New Delhi, Affiliated to J NTUH, NIRF (2023) Rank band:101-150 in Engineering C ategory
C ollege with Potential for Exc ellenc e by UG C ,J NTUH-Rec ognized Researc h C entres:C E,EEE,ME,EC E,C SE Vignana J yothi Nagar,
Pragathi Nagar, Nizampet (S.O.), Hyderabad – 500 090, TS, India.
DEPARTMENT OF CSE-(Cys,DS)& AI&DS
EmployeeSerializationExample.java
19