commit fd0c995cd6be379fe6b4e1d91fe239145c7873d9 Author: Misa Date: Thu Jan 29 14:55:08 2026 +0530 added till 8th a diff --git a/GenericMethodTest.class b/GenericMethodTest.class new file mode 100644 index 0000000..a5f7245 Binary files /dev/null and b/GenericMethodTest.class differ diff --git a/GenericMethodTest.java b/GenericMethodTest.java new file mode 100644 index 0000000..b41d357 --- /dev/null +++ b/GenericMethodTest.java @@ -0,0 +1,22 @@ +//write a java code for generic method + public class GenericMethodTest +{ + public static void printarray(E[] inputarray) + { + for(E element :inputarray) + { + System.out.printf("%s", element); + } + System.out.println(); + } + + public static void main(String[] args) + { + Integer[] intarray = {1,2,3,4,5}; + Character[] chararray = {'a','b','c','d'}; + System.out.println("Array in integer:"); + printarray(intarray); + System.out.println("Array in character"); + printarray(chararray); + } +} \ No newline at end of file diff --git a/MovieBook.class b/MovieBook.class new file mode 100644 index 0000000..efcf139 Binary files /dev/null and b/MovieBook.class differ diff --git a/MovieBook.java b/MovieBook.java new file mode 100644 index 0000000..c84dde1 --- /dev/null +++ b/MovieBook.java @@ -0,0 +1,29 @@ +class TotalEarnings extends Thread +{ + int total = 0; + public void run() + { + synchronized(this) + { + for(int i=1; i<=10; i++) + { + total=total+100; + } + this.notify(); + } + } +} + +public class MovieBook +{ + public static void main(String[] args) throws InterruptedException + { + TotalEarnings te = new TotalEarnings(); + te.start(); + synchronized(te) + { + te.wait(); + System.out.println("Total earnings: " +te.total); + } + } +} \ No newline at end of file diff --git a/MyThread1.class b/MyThread1.class new file mode 100644 index 0000000..fd18bc0 Binary files /dev/null and b/MyThread1.class differ diff --git a/MyThread2.class b/MyThread2.class new file mode 100644 index 0000000..14feaa8 Binary files /dev/null and b/MyThread2.class differ diff --git a/Table.class b/Table.class new file mode 100644 index 0000000..b984acf Binary files /dev/null and b/Table.class differ diff --git a/TestSynchronization2.class b/TestSynchronization2.class new file mode 100644 index 0000000..1d674c3 Binary files /dev/null and b/TestSynchronization2.class differ diff --git a/TestSynchronization2.java b/TestSynchronization2.java new file mode 100644 index 0000000..ae79eea --- /dev/null +++ b/TestSynchronization2.java @@ -0,0 +1,70 @@ +class Table +{ + synchronized void printTable(int n) + { + for(int i=1; i<=5; i++) + { + System.out.println(n*i); + try + { + Thread.sleep(400); + } + catch(Exception e) + { + System.out.println(e); + } + } + } +} + +class MyThread1 extends Thread +{ + Table t; + MyThread1(Table t) + { + this.t = t; + } + public void run() + { + t.printTable(5); + } +} + +class MyThread2 extends Thread +{ + Table t; + MyThread2(Table t) + { + this.t = t; + } + public void run() + { + t.printTable(100); + } +} + +public class TestSynchronization2 +{ + public static void main(String[] args) + { + Table obj = new Table(); + MyThread1 t1 = new MyThread1(obj); + MyThread2 t2 = new MyThread2(obj); + t1.start(); + t2.start(); + } +} + + + + + + + + + + + + + + diff --git a/TotalEarnings.class b/TotalEarnings.class new file mode 100644 index 0000000..8c05407 Binary files /dev/null and b/TotalEarnings.class differ diff --git a/outputs/program 8(a) Generic method.png b/outputs/program 8(a) Generic method.png new file mode 100644 index 0000000..66766e0 Binary files /dev/null and b/outputs/program 8(a) Generic method.png differ diff --git a/outputs/program6 TestSynchronization2.png b/outputs/program6 TestSynchronization2.png new file mode 100644 index 0000000..9ce6713 Binary files /dev/null and b/outputs/program6 TestSynchronization2.png differ diff --git a/outputs/program7 moviebook.png b/outputs/program7 moviebook.png new file mode 100644 index 0000000..4598a28 Binary files /dev/null and b/outputs/program7 moviebook.png differ