Skip to content

Commit 2160914

Browse files
authored
Add files via upload
1 parent b4e85c7 commit 2160914

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1539
-0
lines changed

Diff for: Arraylist.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package lab8;
2+
import java.util.*;
3+
class Student
4+
{
5+
int rollno;
6+
String name;
7+
int age;
8+
9+
Student(int rollno,String name,int age)
10+
{
11+
this.rollno=rollno;
12+
this.name=name;
13+
this.age=age;
14+
}
15+
}
16+
17+
class TestStudent
18+
{
19+
public static void main(String args[])
20+
{
21+
22+
Student s1=new Student(10,"mansi",24);
23+
Student s2=new Student(05,"jeel",20);
24+
Student s3=new Student(15,"divya",23);
25+
Student s4=new Student(07,"jil",19);
26+
Student s5=new Student(13,"Tulsi",15);
27+
Student s6=new Student(04,"vaibhavi",20);
28+
29+
ArrayList<Student> al=new ArrayList<Student>();
30+
al.add(s1);
31+
al.add(s2);
32+
al.add(s3);
33+
al.add(s4);
34+
al.add(s5);
35+
al.add(s6);
36+
37+
for(Student st:al)
38+
System.out.println(st.rollno+" "+st.name+" " + st.age);
39+
}
40+
}

Diff for: Bank.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package Lab4;
2+
public class Bank{
3+
private double amount;
4+
public Bank(){
5+
amount=500.0;
6+
}
7+
public void deposit(double add){
8+
display();
9+
amount=amount+add;
10+
System.out.println("Amount added successfully!");
11+
display();
12+
13+
}
14+
public void withdraw(double sub) throws NotEnoughBalance,ArithmeticException{
15+
if(amount-sub<0)
16+
throw new NotEnoughBalance();
17+
else if (amount-sub<500)
18+
throw new ArithmeticException();
19+
else{
20+
amount=amount-sub;
21+
System.out.println("Withdrawal successful !");
22+
23+
}
24+
25+
}
26+
public void display(){
27+
System.out.println("amount : "+amount);
28+
}
29+
}

Diff for: Client.class

1.17 KB
Binary file not shown.

Diff for: Client.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
import java.io.*;
3+
import java.net.*;
4+
public class Client
5+
{
6+
public static void main(String args[])throws IOException
7+
{
8+
Socket client=new Socket("localhost",3333);
9+
OutputStream s1Out=client.getOutputStream();
10+
InputStream s1In=client.getInputStream();
11+
DataOutputStream dos=new DataOutputStream(s1Out);
12+
String str;
13+
Scanner sc=new Scanner(System.in);
14+
str=sc.nextLine();
15+
dos.writeUTF(str);
16+
DataInputStream dis=new DataInputStream(s1In);
17+
String st=new String (dis.readUTF());
18+
System.out.println(st);
19+
dos.close();
20+
s1Out.close();
21+
dis.close();
22+
s1In.close();
23+
client.close();
24+
}
25+
}

Diff for: Demo2c.java

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test;
2+
import lab2.*;
3+
class Demo2c
4+
{
5+
public static void main(String arg[])
6+
{
7+
N ob1=new N(6.013);
8+
ob1.display();
9+
}
10+
}

Diff for: Demo9.java

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package lab9;
2+
import java.io.FileInputStream;
3+
import java.io.FileOutputStream;
4+
public class Demo9
5+
{
6+
public static void main(String a[])
7+
{
8+
FileInputStream ob=null;
9+
FileOutputStream obj=null;
10+
try{
11+
ob= new FileInputStream("abc.txt");
12+
obj=new FileOutputStream("xyz.txt");
13+
14+
byte[] buffer=new byte[1024];
15+
int i;
16+
while((i=ob.read(buffer))!=-1)
17+
{
18+
obj.write(buffer,0,i);
19+
//System.out.println((char)i);
20+
//i=ob.read();
21+
}
22+
}
23+
catch(Exception e)
24+
{
25+
System.out.println("\nIOException");
26+
}
27+
finally{
28+
try{
29+
ob.close();
30+
obj.close();
31+
}
32+
catch(Exception e)
33+
{
34+
System.out.println("\nIOException");
35+
}
36+
}
37+
}
38+
}

Diff for: DemoFib.java

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package test;
2+
import lab1.Fib;
3+
class DemoFib
4+
{
5+
public static void main(String a[])
6+
{
7+
Fib ob3 = new Fib();
8+
ob3.run();
9+
}
10+
}

Diff for: DemoThread.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package test;
2+
import lab5.MyThread;
3+
class DemoThread
4+
{
5+
public static void main(String a[])
6+
{
7+
MyThread ob1=new MyThread('A',500);
8+
ob1.start();
9+
MyThread ob2=new MyThread('C',200);
10+
ob2.start();
11+
System.out.println("End of main");
12+
}
13+
}

Diff for: DemoThread2.java

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package test;
2+
import lab5.*;
3+
class DemoThread2
4+
{
5+
public static void main(String a[])
6+
{
7+
counter c=new counter();
8+
MyThread2 ob1=new MyThread2(1,c);
9+
ob1.start();
10+
//MyThread2 ob2=new MyThread2(0,c);
11+
12+
//ob2.start();
13+
}
14+
}

Diff for: Demomerge.java

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package lab9;
2+
import java.io.FileInputStream;
3+
import java.io.FileOutputStream;
4+
public class Demomerge
5+
{
6+
public static void main(String a[])
7+
{
8+
FileInputStream ob1=null;
9+
FileInputStream ob2=null;
10+
FileOutputStream obj=null;
11+
try{
12+
ob1= new FileInputStream("abc.txt");
13+
ob2= new FileInputStream("xyz.txt");
14+
obj=new FileOutputStream("final.txt");
15+
16+
byte[] buffer=new byte[1024];
17+
int i;
18+
while((i=ob1.read(buffer))!=-1)
19+
{
20+
obj.write(buffer,0,i);
21+
}
22+
while((i=ob2.read(buffer))!=-1)
23+
{
24+
obj.write(buffer,0,i);
25+
}
26+
}
27+
catch(Exception e)
28+
{
29+
System.out.println("\nIOException");
30+
}
31+
finally{
32+
try{
33+
ob1.close();
34+
ob2.close();
35+
obj.close();
36+
}
37+
catch(Exception e)
38+
{
39+
System.out.println("\nIOException");
40+
}
41+
}
42+
}
43+
}

Diff for: Hiding.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package test;
2+
import lab2.*;
3+
class Hiding
4+
{
5+
public static void main(String a[])
6+
{
7+
T t=new T("hello",4);
8+
}
9+
}

Diff for: Incr.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package lab5;
2+
public class Incr implements Runnable
3+
{
4+
public Thread t;
5+
public int i=1;
6+
public Incr()
7+
{
8+
t=new Thread(this,"one");
9+
t.start();
10+
}
11+
public void run()
12+
{
13+
while(true)
14+
{
15+
try{
16+
System.out.println(i++);
17+
Thread.sleep(1000);
18+
}
19+
catch(Exception e)
20+
{
21+
System.out.println("caught");
22+
}
23+
}
24+
}
25+
}

Diff for: IntegerNumberMultiplication.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package lab3;
2+
public class IntegerNumberMultiplication implements Multiplication
3+
{
4+
int a,b,ans;
5+
public IntegerNumberMultiplication(){}
6+
public IntegerNumberMultiplication(int a,int b)
7+
{
8+
this.a=a;
9+
this.b=b;
10+
}
11+
public void multiplication()
12+
{
13+
ans=a*b;
14+
}
15+
public void display()
16+
{
17+
System.out.println("Answer:"+ans);
18+
}
19+
}

Diff for: Java-ala.pptx

616 KB
Binary file not shown.

Diff for: M.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package lab2;
2+
public class M
3+
{
4+
float a;
5+
String b;
6+
public M(float c,String d)
7+
{
8+
a=c;
9+
b=d;
10+
}
11+
public float Initialize1()
12+
{
13+
return a;
14+
}
15+
public String Initialize2()
16+
{
17+
return b;
18+
}
19+
}

Diff for: Main1.java

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package main;
2+
import lab1.*;
3+
import test.*;
4+
import java.util.Scanner;
5+
public class Main1
6+
{
7+
public static void merge()
8+
{
9+
int x[]={5,8,3,7,1};
10+
Array a1=new Array();
11+
Array a2=new Array(x);
12+
Array a3;
13+
a1.read();
14+
a3=a1.merging(a2);
15+
a1.display();
16+
a2.display();
17+
System.out.println("The merged array is:");
18+
a3.display();
19+
System.out.println("The sorted array is:");
20+
a3.sort(a3);
21+
a3.display();
22+
}
23+
public static void matrix()
24+
{
25+
int d[][]={{1,2,3},{4,5,6},{7,8,9}};
26+
Matrix m1=new Matrix(3,3);
27+
Matrix m2=new Matrix(d);
28+
Matrix m3;
29+
Matrix m4;
30+
m1.read();
31+
m3=m1.add(m2);
32+
m4=m1.multiply(m2);
33+
m1.display();
34+
m2.display();
35+
m3.display();
36+
m4.display();
37+
}
38+
public static void main(String a[])
39+
{
40+
int ca;
41+
Scanner sc=new Scanner(System.in);
42+
System.out.println("\n1.Reverse a number\n2.cmd line calc\n3.Fibonacci series\n4.Merge 2 Arrays in 3rd and also sort\n5.To add and multiply two int matries");
43+
System.out.println("Enter your choice: ");
44+
ca= sc.nextInt();
45+
switch(ca)
46+
{
47+
case 1:
48+
{
49+
int ans;
50+
reverse d1=new reverse();
51+
Scanner sca=new Scanner(System.in);
52+
int x= sca.nextInt();
53+
ans=d1.rev(x);
54+
System.out.println("Reverse of"+x+" is "+ans);
55+
break;
56+
}
57+
case 2:
58+
{
59+
int x = Integer.parseInt(a[0]);
60+
int y = Integer.parseInt(a[2]);
61+
char c = a[1].charAt(0);
62+
Cal ob2 = new Cal(x,y,c);
63+
ob2.run();
64+
break;
65+
}
66+
case 3:
67+
{
68+
Fib ob3 = new Fib();
69+
ob3.run();
70+
break;
71+
}
72+
case 4:
73+
merge();
74+
break;
75+
case 5:
76+
matrix();
77+
break;
78+
default:
79+
System.out.println("enter a valid choice");
80+
}
81+
}
82+
}
83+

0 commit comments

Comments
 (0)