java 9
java 9
class ThrowEx
try
catch(NullPointerException e)
try
fun();
catch(NullPointerException e)
{
System.out.println(".......catch of main() method......");
Output
class FinallyBlockEx{
try{
int data=25/0;
System.out.println(data);
catch(ArithmeticException e){
finally{
Output
c) Write a JAVA program for creation of Java Built-in Exceptions
IOException
import java.io.*;
class IOExceptionEx {
FileInputStream f = null;
f = new FileInputStream("abc.txt");
int i;
System.out.print((char)i);
f.close();
Output
InterruptedException
class InterruptedExceptionEx{
System.out.println("......Main Thread...."+i);
Thread.sleep(1000);
Output
StringIndexOutOfBoundsException
class StringIndexOutOfBoundEx {
try {
System.out.println(c);
catch (StringIndexOutOfBoundsException e) {
Output
VotingException() {
}//userdifined exception
if(age<19)
class UserDefinedException {
int age=Integer.parseInt(args[0]);
try {
VotingTest.displayEligibility(age);
catch(VotingException e)
}
Output