Catch(Exception e){
}
in that what is Exception and purpose of that in that place
exactly?
Answer Posted / anjani kumar jha
Before understand the concept of Catch u have to understand
the concept of try,that is why try?
Try-------it is used when we know that some piece of code is
going to throw some exception example when u are dividing
somthing/0 means it may throw exception so we use the try
block and put that code inside the try block
Catch:--------Every try there must be catch or finally
block. Catch is used to catch to exception.As for example
the division example may throw airthmatic exception so will
declare this exception in catch like
Catch(AirthmaticException ae)
{
System.out.println("hi cannt divide by zero");
System.out.println(ae);
}
| Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
Explain different ways of creating a thread?
What happens if a try-catch-finally statement does not have a catch clause to handle an exception that is thrown within the body of the try statement?
What are three advantages of using functions?
How do I type unicode?
Is 0 an even number?
What is externalizable?
What is main function purpose?
Can we store variables in local blocks?
When a byte datatype is used?
Name few java.lang classes introduced with java 8 ?
Can I extend singleton class in java?
How many types of interfaces are there?
Can we override static methods in java?
What is widening and narrowing in java? Discuss with an example.
What is the base class of all exception classes?