Posts

4.EXCEPTION HANDLING IN JAVA

  4.EXCEPTION HANDLING IN JAVA Source Code:  import java.io.*; class Predefined{ void ArithmeticExcp(){ try{ int a=20,b=0,c; c=a/b; System.out.println("Result:"+c); } catch(ArithmeticException e){ System.out.println("Arithmetic Exception:Division by zero"); } } void StrindOutofBoundExcp(){ try{ String s="Java Programming"; char c=s.charAt(25); System.out.println(c); } catch(StringIndexOutOfBoundsException e) { System.out.println("String out of Bound Exception:character Index out of Range"); } } void ArrayOutofBoundExcp(){ try{ int a[]=new int[5]; a[8]=9; } catch(ArrayIndexOutOfBoundsException e) { System.out.println("Array out of Bound Exception: Index out of Range"); } } void FileNotFoundExcp() throws FileNotFoundException{ try{ File file=new File("D://sample.txt"); FileReader fr=new FileReader(file); } catch(FileNotFoundException e) { System.out.println("File Not Found Exception: File does not exist"); } } } public...

3.MULTITHREADING IN JAVA

  3.MULTITHREADING IN JAVA Source Code:  class SquareThread extends Thread { public void run(){ try { for(int i=1;i<=5;i++) { System.out.println("Square of " +i +" is" +(i*i)); Thread.sleep(1000); } } catch(Exception e) { System.out.println(e); } } } class CubeThread extends Thread{ public void run(){ try { for(int i=1;i<=5;i++) { System.out.println("Cube of " +i +" is" +(i*i*i)); } } catch(Exception e) { System.out.println(e); } } } class SquareRootThread extends Thread{ public void run(){ try { for(int i=1;i<=5;i++) { System.out.println("Square Root of " +i +" is" +(i*0.5)); Thread.sleep(10); } } catch(Exception e) { System.out.println(e); } } } class EmptyThread extends Thread{ public void run(){ for(int i=1;i<=5;i++) { System.out.println("Hello Thread"); } } } public class ThreadExample { public static void main(String[] args) { System.out.println("Multithreading in Java"); System.out.printl...

2)implementation of pakage

 2.Implementation of package Source Code  package pack1;  public class myclass { public void display() { System.out.println("Implementation of package"); } } package pack1; public class myclass1 { public static void main(String[] args) { myclass m=new myclass(); m.display(); } } Output: Implementation of package

1Single Inheritance and multilevel inheritance

 class dog { String name; public void rv1() { System.out.println("Bow Bow"); } } class cat extends dog { public void rv2() { System.out.println("Meow Meow"); } } public class prg1 { public static void main(String[] args) { cat c=new cat(); c.rv2(); c.rv1(); } } Output: Meow Meow Bow Bow 2)b)Multilevel inheritance  Source Code:  class colour { public void red() { System.out.println("Apple -red color"); } } class fruit extends colour { public void orange() { System.out.println("orange – orange color"); } } class name extends fruit { public void yellow() { System.out.println("lemon – yellow color"); } } public class prg11 { public static void main(String[] args) { name a=new name(); a.red(); a.orange(); a.yellow(); } } Output: Apple - red color Orange – orange color Lemon – yellow colo c)Hierarchical inheritance Source Code:  class cs { public void HOD() { System.out.println("Head of Department"); } } class first extends cs { pub...

java last program

https://drive.google.com/file/d/1I6ihCTMeSedeiFzbad9ze1Dqv9Er-fQt/view?usp=sharing

total source pdf

https://drive.google.com/file/d/1OrIJn5Mb3AdLcr0ioR3O-7SOvaBCj2Rg/view?usp=sharing