11 a.
code execute and debug programs in java to handle checked exceptions
package a;
import [Link];
import [Link];
public class checked {
public static void main(String args [])throws IOException
FileWriter obj=new FileWriter("C:\\Users\\BETP LAB 01\\Desktop\\b");
[Link]("file written successfully");
Output
file written Successfully
b. code execute and debug program to java to unchecked exceptions.
package a;
import [Link];
import [Link];
public class unchecked {
public static void main(String args [])throws IOException
int i=10/0;
[Link](i);
}
Output
Exception in thread "main" [Link]: / by zero
at a/[Link]([Link])
c. write a program to implement file writer.
package a;
import [Link].*;
public class MyFileReader {
public static void main(String [] args)throws IOException
FileWriter fw=new FileWriter("C:\\Users\\BETP LAB 01\\Desktop\\[Link]");
String s="good morning to all 4th sem students";
char ch[]=[Link]();
for(int i=0;i<[Link];i++)
[Link](ch[i]);
[Link]();
Output
12) Design an interface it like one that build different types of toys and check compliancre with
ISP
package a;
public interface barkable {
public void bark();
interface flyable
public void fly();
class dog implements barkable
public void bark()
[Link]("dog is barking");
class bird implements flyable
public void fly()
[Link]("bird is flyable");
class java
{
public static void main(String [] args)
dog a1=new dog();
bird a2=new bird();
[Link]();
[Link]();
Output
dog is barking
bird is flyable
[Link] memory monitoring tool and observe how jum allocates memory.
package a;
public class jconso {
public static void main(String [] args)
Thread t1=new Thread1();
[Link]();
[Link]("thread 1 started");
class Thread1 extends Thread
public void run()
{
while(true)
Output
thread 1 started