Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


the use of try and ffinally keyword



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

Post New Answer

More Advanced Java Interview Questions

What is threadfactory?

0 Answers  


Difference Between java & javax

5 Answers   Sun Microsystems, Wipro,


What is permgen or permanent generation?

0 Answers  


What is the name of the state, when a thread is executing?

4 Answers  


Brief description about local interfaces?

0 Answers  






What is Stream Tokenizer?

0 Answers   TCS,


iam writing the contents to a excel through I/O i am putting first statement as WRITE and then READ(from excel) immediately..later user complains that he is not getting the date by using READ ..wat could be the situation

3 Answers   iGate,


To identify IDL language what mapping mechanism is used?

0 Answers  


What if the static modifier is removed from the signature of the main method?

0 Answers  


What are the various thread priorities?

1 Answers  


How to determine SGA site?

0 Answers   Wipro,


What is Servlet Filter And What does it work?

1 Answers   TCS,






Categories