the use of try and ffinally keyword
Answer / xavier
try and finally are keywords associated with exception
handling(run time errors)
try block provides two benefits it allows you to fix the error.
it prevents program from automatically terminating
e.g.
class Exception_handling
{
public static void main(String args[]){
try{
int d=0;
int x= 42/d;
System.out.println("this will not be printed");
}
catch(Exception e)(
System.out.println("this will be printed");
}
}
}
you might observe that in above code the line after int
x=42/d is not printed but there are certain operations that
you need to perform before proceeding further and finally
would serve this purpose
class Exception_handling
{
public static void main(String args[]){
try{
int d=0;
int x= 42/d;
System.out.println("this will not be printed");
}
catch(Exception e)(
System.out.println("this will be printed");
}
finally{
system.out.println("this will be printed");
}
}
}
| Is This Answer Correct ? | 10 Yes | 0 No |
Is the ternary operator written x : y ? Z or x ? Y : z ?
what do u mean by java bean??
Why are some of the class and element names counter-intuitive?
What do you need to set-up a cluster with jboss?
What is ioc concept?
Why use POJO when I can use hashmap
What is the name of the state, when a thread is executing?
what are memory considerations of jsp compares to other web components?
Define prototype?
What are the types of scaling?
what is Static binding?
Is infobus easy to use?