keshav pradeep ramanath wrote:Create a class with a main( ) that throws an object of class Exception inside a try block.
Give the constructor for Exception a String argument.
Catch the exception inside a catch clause and print the String argument.
Add a finally clause and print a message to prove you were there.
Please give the solution for the same."Please explain how to use Exception constructor".
Is it possible to throw an exception in try block
The important thing is not to stop questioning.Curiosity has its own reason for existing.
Vijay Tidake wrote:Hi,
Is it possible to throw an exception in try block
Its possible.
Please suggest the right way of using the constructor!!I m not just getting as to hw it works!!
The important thing is not to stop questioning.Curiosity has its own reason for existing.
Vijay Tidake wrote:Hi,
Please suggest the right way of using the constructor!!I m not just getting as to hw it works!!
I/m not clear about your doubt.What are you trying to say?
1.How to use the constructor
2.How to write your own exception
3.How to throw an exception from try block.
4.How throw works in try catch block
Thanks
Im am getting an error saying "cannot find symbol"!!
Maneesh Godbole wrote:
keshav wrote:K tge hw
Please UseRealWords
keshav pradeep ramanath wrote:
Yes!!I have defined "msg" in the Exception constructor as" FirstException(String msg){ String msg="this is bound to work";
System.out.println(msg);
} "
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |