















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
















































Kovilpalayam Department of Computer Science and Applications CORE LAB IV-JAVA PROGRAMMING (For the Academic Year 2022- 2023 - ODD Semester) NAME : ….................................................................... REGISTER NO : ………………………………………………. CLASS : …………………………………………….. Certified Bonafide record of work done by …………………………………………………………………………………. Staff-In-Charge Head of the Department Submitted for the University Examination held on ………………………. Internal Examiner External Examiner
S.No Date PARTICULARS Page No Signature 1 STRING EXTRACT 2 MULTIPLE INHERITANCE 3 EXCEPTION HANDLING 4 MULTITHREADING 5 SEVERAL SHAPES 6 MY DETAILS 7 MULTIPLE SELECTION LIST BOX 8 MULTILINE TEXT 9 MENU CREATION 10 MOUSE EVENT DISPLAY 11 SEVERAL SHAPES USING MOUSE 12 FILE PROCESS
class Stringextract { public static void main(String args[]) { String s1; s1=new String("WELCOME TO JAVA PROGRAMMING"); System.out.println("The given string is:"+ s1); System.out.println("The Extracted portion:" + s1.substring(10,16)); } }
The Given string is: WELCOME TO JAVA PROGRAMMING The Extracted portion: JAVA
class Arith { int a,b; } interface Addition { void add(); } interface Subtraction { void sub(); } class Operation extends Arith implements Addition,Subtraction { public void add() { a=10+5; System.out.println("Addition value:"+ a);
public void sub() { b=20-10; System.out.println("Subtraction value:"+ b); } } class Interface { public static void main(String args[]) { Operation op=new Operation(); op.add(); op.sub(); } }
import java.util.*; class Payout extends Exception { public static void main(String args[]) { Scanner s=new Scanner(System.in); System.out.println("Enter a Salary"); int salary=s.nextInt(); System.out.println("Enter a Days"); int days=s.nextInt(); try { int total=salary/days; if(total>3000) { throw new ArithmeticException("PAY OUT OF BOUNDS"); } System.out.println("Salary:"+ total);
Enter a Salary: 5000 Enter a Days: 30 Salary: Enter a Salary: 1000000 Enter a Days: 10 java.lang.ArithmeticException: PAY OUT OF BOUNDS
System.out.println(i+"2="+i2); } System.out.println("Thread B Exited"); } } class ThrC extends Thread { public void run() { System.out.println("Thread C started"); for(int i=1;i<=5;i++) { System.out.println(i+"3="+i3); } System.out.println("Thread C Exited"); } } class Priority
public static void main(String args[]) { ThrA a=new ThrA(); ThrB b=new ThrB(); ThrC c=new ThrC(); c.setPriority(1); b.setPriority(5); c.setPriority(10); a.start(); b.start(); c.start(); } }
Java file: import java.applet.; import java.awt.; public class Shapes extends Applet { public void paint(Graphics g) { g.drawString("Line",25,40); g.drawLine(60,60,150,60); g.drawString("Square",25,80); g.drawRect(60,90,90,90); g.drawString("Rectangle",25,200); g.drawRect(60,210,120,90); g.drawString("Circle",25,320); g.drawOval(60,330,90,90); g.drawString("Square",25,450); g.drawOval(60,460,120,90); }