Professional Documents
Culture Documents
Write A Java Program To Print Table of Entered Number. Program
Write A Java Program To Print Table of Entered Number. Program
Practical 1A
Program:
Output:
Practical 1B
Program:
Output:
Practical 1C
Program:
Output:
Practical 2A
Program:
Output:
Practical 2B
Program:
Output:
Practical 2C
Program:
Output:
Practical 3A
Write a program to count number of digits, spaces and special characters in a string
Program:
Output:
Practical 3B
Write a program to add the elements of an array of string by converting them in long
Program:
Output:
Practical 3C
Write a java program to print the smallest and largest number in an array
Program:
Output:
Practical 4A
Program:
Output:
Practical 4B
Program:
Output:
Practical 4C
Program:
Output:
Practical 5A
Program:
Output:
Practical 5B
Program:
Output:
Practical 5c:
Program:
Interface S {
Interface T extends S{
@Override
@Override
Ob.show();
Ob.display();
}
Output:
Practical 6B
Program:
Import java.util.Scanner;
Class Prac6B {
Int I, j;
Mat1[i][j] = scanner.nextInt();
Mat2[i][j] = scanner.nextInt();
System.out.print(mat3[i][j] + “ “);
System.out.println();
}
Output:
Practical 6c
Program:
Import java.util.Scanner;
Class Main {
Int base;
Base = scanner.nextInt();
Mat1[i][j] = scanner.nextInt();
Mat2[i][j] = scanner.nextInt();
System.out.println(“\nMultiplying the matrices..”);
System.out.print(mat3[i][j] + “ “);
System.out.println();
}
Output:
Practical 7b:
Program:
Import java.util.Vector;
Class Pract7b
System.out.println(Thread.currentThread().getName());
For(int i=0;i<10;i++)
New Thread(“”+i)
System.out.println(“Thread:”+getName()+”running”);
}.start();
}
Output:
Practical 7c:
Write a program to execute threads
Program:
Import java.io.*;
System.out.println(“Start A”);
For(int i=1;i<=5;i++)
System.out.println(“Thread A i:”+i);
System.out.println(“Exit A”);
{
Public void run()
System.out.println(“Start B”);
For(int j=1;j<=5;j++)
System.out.println(“Thread B j:”+j);
System.out.println(“Exit B”);
}
System.out.println(“Start C”);
For(int k=1;k<=5;k++)
System.out.println(“Thread C k:”+k);
System.out.println(“Exit C”);
System.out.println(“Start D”);
For(int m=1;m<=5;m++)
System.out.println(“Thread D m:”+m);
System.out.println(“Exit D”);
}
}
Class Pract7c
New A().start();
New B().start();
New C().start();
New D().start();
}
Output:
Practical 8a
Write a program to read a file
Program:
Import java.io.*;
Is.read(a);
For (byte b : a) {
Char k=(char)b;
System.out.print(k+”-“);
Output:
Text1.t
Practical 8b:
Write a Java lrogram to copy contents of one text file to another
Program:
Import java.io.*;
Class Main {
FileInputStream fis=null;
FileOutputStream fos=null;
Try {
Fis=new FileInputStream(inF);
Fos=new FileOutputStream(outF);
Int length;
While((length=fis.read(buff))>0)
Fos.write(buff,0,length);
Fis.close();
Fos.close();
System.out.println(“Contents Copied…”);
} catch (Exception e) {
e.printStackTrace();
}}}
text2.txt before execution:
String s1,s2,s3;
S1= sc.nextLine();
S2= sc.nextLine();
S3= sc.nextLine();
Byte b1[]=s1.getBytes();
Fos.write(b1);
Byte b2[]=s2.getBytes();
Fos.write(b2);
Byte b3[]=s3.getBytes();
Fos.write(b3);
Fos.close();
System.out.println(“File Created”);
}
Output:
Text file:
Practical 9c:
Write a Java program to execute exception handling
Program:
Class Pract9c
Int a[]={5,10};
Int b=5;
Try
Int x=a[2]/(b-a[0]);
}
Catch(ArithmeticException e)
Catch(ArrayIndexOutOfBoundsException e)
Finally
Int y=a[1]/a[0];
System.out.println(“Result:-“+y);
}
}
}
Output: