Skip to content

prabhutm/2024_PRACTICAL2_A

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Aim : To write a program that demonstrates how various exceptions are caught with catch.

Algorithm: Step 1: Class Design  Define a class named ExceptionA which inherits from the built-in class Exception.  Define ExceptionA class with appropriate onstructors and methods if needed.  Define a class named ExceptionB which inherits from ExceptionA.  Define ExceptionB class with appropriate constructors and methods if needed. Step 2: Creating main()  Declare variables and objects as needed.  Use try blocks to encapsulate code sections where exceptions may occur. Step 3: Within each try block:  Throw exceptions of types ExceptionA, ExceptionB and IOException.  For NullPointerException, initialize a null string and calculate the length of the string. [Trying to access the length method on null string results in an Exception] Step 4: Use catch blocks to catch exceptions of type Exception.  Handle each caught exception appropriately within the catch blocks.

About

2024_PRACTICAL2_A

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors