Aman Tarafdar XI - B
Aman Tarafdar XI - B
PRACTICAL FILE
BATCH 2024-25
NAME : AMAN TARAFDAR
CLASS/ SECTION : XII - B
UNIQUE ID : 8071057
INDEX NUMBER :
1
CERTIFICATE OF AUTHENTICITY
2
TABLE OF INDEX
TOPICS
S.NO PG NO.
Time class to add two times and print the final time using
4. objects
ARRAYS
Checking if the Matrix is symmetric or not. Also calculates the
6. sum of left and right diagonals of the matrix
3
Program to remove consecutive repeated characters by
14. replacing with its single occurrence
DATA STRUCTURE
Program to implement Stack
16.
INHERITANCE
Calculating salary of an employee by taking data from two
23. classes Employee and Salary
RECURSION
4
Finding out sum of the series recursively
28. x2/1! + x4/3!+x6/5!+….xn/(n-1)!
MISCELLANEOUS PROGRAMS
Program to perform Insertion Sort in a single dimension array
33.
QUESTION 1
5
ALGORITHM
SOURCE CODE
import java.util.Scanner;
6
class Collection {
private int[] ar; Collection commonCollection = new
private int len; Collection(k);
for (int i = 0; i < k; i++) {
public Collection() { commonCollection.ar[i] = temp[i];
this.len = 100; }
this.ar = new int[len];
} return commonCollection;
}
public Collection(int len) {
this.len = len; public void display() {
this.ar = new int[len]; System.out.println("Array elements:");
} for (int i = 0; i < len; i++) {
System.out.print(ar[i] + " ");
public void input() { }
Scanner sc = new Scanner(System.in); System.out.println();
System.out.println("Enter " + len + " }
elements:");
for (int i = 0; i < len; i++) { public static void main(String[] args) {
ar[i] = sc.nextInt(); Collection c1 = new Collection(10);
} Collection c2 = new Collection(20);
}
System.out.println("Input for Collection
public Collection common(Collection 1:");
other) { c1.input();
int[] temp = new int[len]; System.out.println("Input for Collection
int k = 0; 2:");
c2.input();
for (int i = 0; i < this.len; i++) {
for (int j = 0; j < other.len; j++) { Collection common = c1.common(c2);
if (this.ar[i] == other.ar[j]) { System.out.println("Common
temp[k++] = this.ar[i]; elements:");
break; common.display();
} }
} }
}
7
OUTPUT
QUESTION 2
8
ALGORITHM
9
SOURCE CODE
import java.util.Scanner; }
10
VARIABLE DESCRIPTION TABLE
OUTPUT
QUESTION 3
11
ALGORITHM
12
SOURCE CODE
import java.util.Scanner; }
}
class Collection {
private int[] ar; public Collection common(Collection
private int len; other) {
int[] temp = new int[len];
public Collection() { int k = 0;
this.len = 100;
this.ar = new int[len]; for (int i = 0; i < this.len; i++) {
} for (int j = 0; j < other.len; j++) {
if (this.ar[i] == other.ar[j]) {
public Collection(int len) { temp[k++] = this.ar[i];
this.len = len; break;
this.ar = new int[len]; }
} }
}
public void input() {
Scanner sc = new Scanner(System.in); Collection commonCollection = new
System.out.println("Enter " + len + " Collection(k);
elements:"); for (int i = 0; i < k; i++) {
for (int i = 0; i < len; i++) { commonCollection.ar[i] = temp[i];
ar[i] = sc.nextInt(); }
13
return commonCollection; System.out.println("Input for Collection
} 1:");
c1.input();
public void display() { System.out.println("Input for Collection
System.out.println("Array elements:"); 2:");
for (int i = 0; i < len; i++) { c2.input();
System.out.print(ar[i] + " ");
} Collection common = c1.common(c2);
System.out.println(); System.out.println("Common
} elements:");
common.display();
public static void main(String[] args) { }
Collection c1 = new Collection(10); }
Collection c2 = new Collection(20);
OUTPUT
14
QUESTION 4
15
ALGORITHM
SOURCE CODE
import java.util.Scanner;
public Collection() {
class Collection { this.len = 100;
private int[] ar; this.ar = new int[len];
private int len; }
16
commonCollection.ar[i] = temp[i];
public Collection(int len) { }
this.len = len;
this.ar = new int[len]; return commonCollection;
} }
17
OUTPUT
QUESTION 5
18
ALGORITHM
19
SOURCE CODE
import java.util.Scanner; }
20
VARIABLE DESCRIPTION TABLE
OUTPUT
21
QUESTION 6
22
ALGORITHM
23
SOURCE CODE
import java.util.Scanner; }
24
} System.out.println("Input for Collection
1:");
public void display() { c1.input();
System.out.println("Array elements:"); System.out.println("Input for Collection
for (int i = 0; i < len; i++) { 2:");
System.out.print(ar[i] + " "); c2.input();
}
System.out.println(); Collection common = c1.common(c2);
} System.out.println("Common
elements:");
public static void main(String[] args) { common.display();
Collection c1 = new Collection(10); }
Collection c2 = new Collection(20); }
OUTPUT
25
QUESTION 7
ALGORITHM
26
SOURCE CODE
import java.util.Scanner; }
27
VARIABLE DESCRIPTION TABLE
OUTPUT
QUESTION 8
28
ALGORITHM
SOURCE CODE
import java.util.Scanner;
public Collection() {
class Collection { this.len = 100;
private int[] ar; this.ar = new int[len];
private int len; }
29
commonCollection.ar[i] = temp[i];
public Collection(int len) { }
this.len = len;
this.ar = new int[len]; return commonCollection;
} }
30
OUTPUT
31