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 |
What value does read() return when it has reached the end of a file?
Where does the session Object stores? If 100 users are connecting to the server. How does it recognize which session belongs to which user?
5 Answers HCL, Mobillo Venture,
What are externizable interface?
In inglish: How to convert jar to exe files? Em português: Como converter arquivos .jar para .exe?
What is Remote Server?
What is resource bundle?
What is metaspace?
Explain about RMI Architecture?
What invokes a thread?s run() method?
Can I use javascript to submit a form?
What is meant by method chaining?
How will the struts know which action class to call when you submit a form?