Docsity

java prgramming crouse, Summaries of Java Programming

Toggle sidebar
bg1
KATHIR COLLEGE OF ARTS AND
SCIENCE
(AFFILIATED TO BHARATHIAR UNIVERSITY)
“WISDOMTREE”, NEELAMBUR, COIMBATORE–641062.
NAME :
REGNO :
B.SC (COMPUTER SCIENCE WITH DATA ANALYTICS)
CORE LAB - IV
PROGRAMMING LAB – JAVA
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f

Partial preview of the text

Download java prgramming crouse and more Summaries Java Programming in PDF only on Docsity!

KATHIR COLLEGE OF ARTS AND

SCIENCE

(AFFILIATED TO BHARATHIAR UNIVERSITY) “WISDOMTREE”, NEELAMBUR, COIMBATORE–641062. NAME : REGNO :

B.SC (COMPUTER SCIENCE WITH DATA ANALYTICS)

CORE LAB - IV

PROGRAMMING LAB – JAVA

KATHIR COLLEGE OF ARTS AND SCIENCE (AFFILIATED TO BHARATHIAR UNIVERSITY) “WISDOM TREE”, NEELAMBUR, COIMBATORE – 641 062. DEPARTMENT OF COMPUTER SCIENCE WITH DATA ANALYTICS NAME : REG.NO : SUBJECT CODE AND NAME : CLASS : Certified that this is the bonafide record of work done by Mr. /Ms. Of B.SC (Computer Science with Data Analytics) in Laboratory during the academic year 2023- 2024. Faculty Incharge Head of the Department

Submitted for the Practical Examination held on___________

Internal Examiner External Examiner

AIM:

ALGORITHM:

Ex.No :

Date :

STACK EXTRACTION

Program: import java.io.*; class prgone { public static void main(String args[])throws IOException { DataInputStream x=new DataInputStream(System.in); String s,s1; int start,end; System.out.println("Enter the string"); s=x.readLine(); System.out.println("Enter starting position"); start=Integer.parseInt(x.readLine()); System.out.println("Enter the ending position"); end=Integer.parseInt(x.readLine()); s1=s.substring(start,end); System.out.println("the given string is:"+s); System.out.println("The extracted string is:"+s1); } }

AIM:

ALGORITHM:

Ex.No :

Date :

MULTIPLE INHERITANCE USING INTERFACES

PROGRAM: import java.io.*; interface A { int a=1; public void getdata(); } interface B { int b=20; public void putdata(); } class C implements A,B { public void getdata() { System.out.println("the value of A:"+a); } public void putdata() { System.out.println("the value of B:"+b); } public void cal() { int sum=a+b; System.out.println("the sum of 2 number are="+sum); } } class prgtwo { public static void main(String args[]) { C c1=new C(); c1.getdata(); c1.putdata(); c1.cal(); } }

AIM:

ALGORITHM:

Ex.No :

Date :

PAYOUT-OF-BOUNDS EXCEPTION

PROGRAM: import java.io.*; class prg extends Exception { prg() { String s; System.out.println("sorry your cheque is dishonoured"); } } public class prgthree { public static void main(String p[])throws IOException { DataInputStream d=new DataInputStream(System.in); int bal=10000,wd; System.out.println(); System.out.println(".........."); System.out.println("pay out of bounds"); System.out.println(".........."); System.out.println("enter the withdraw amount"); wd=Integer.parseInt(d.readLine()); if(wd>=bal) { System.out.println(); new prg(); System.out.println(); } else { System.out.println(); System.out.println("your cheque is passed"); System.out.println(); } } }

AIM:

ALGORITHM:

Ex.No :

Date :

MULTITHREADING WITH PRIORITIES

PROGRAM: import java.io.; class A extends Thread { public void run() { for(int i=1;i<=5;i++) { System.out.println(i+""+5+"="+(i5)); } System.out.println("END OF THE 1st THREAD"); } } class B extends Thread { public void run() { for(int j=1;j<=7;j++) { System.out.println(j+""+7+"="+(j*7)); } System.out.println("END OF THE 2nd THREAD"); } } class C extends Thread { public void run() {

Output: RESULT:

AIM:

ALGORITHM:

Ex.No:

Date :

OUTPUT:

RESULT:

AIM:

ALGORITHM:

Ex.No :

Date :