ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   To Refer this Site to Your Friends   Click Here
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
What is 'finally' method in Exceptions?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is 'finally' method in Exceptions?
Answer
# 1
this  method will execute in any case whether an exeption 
is aughat or not
 
Is This Answer Correct ?    3 Yes 0 No
Guest
 
  Re: What is 'finally' method in Exceptions?
Answer
# 2
finally method is used to conserve the resources before the
exception is being caught
 
Is This Answer Correct ?    0 Yes 1 No
Ravikiran(aptech Mumbai)
 
 
 
  Re: What is 'finally' method in Exceptions?
Answer
# 3
The finally method will be executed after a try or catch
execution. 
It is mainly used to free up resources.
The codes that must be executed, irrespective of whether the
exception is occurred or not, will be included in the
finally block.

See the following simple example to demonstrate the syntax 
 public class FinallyExample
{

    public static void main(String args[])
    {

        try
        {
            // the code that may cause an exception
        }
        catch (Exception e)
        {
            // the code to be executed, when the exception
occurs
        }
        finally
        {
            // code to be executed irrespective of the
occurrence of exception
        }
    }
}

When using finally, the catch block is not mandatory.
ie, a try block must be followed by a catch or finally block.
 
Is This Answer Correct ?    1 Yes 0 No
Sumesh Babu R
 
  Re: What is 'finally' method in Exceptions?
Answer
# 4
ALL ANSWERS GIVEN ABOVE ARE WRITE.........


BUT

ONLY CASE THAT CAN SUPPRESS THE FINALY BLOCK IS

 public class SupressFinallyExample
{

    public static void main(String args[])
    {

        try
        {
            // the code that may cause an exception
             //System.exit(0);
        }
        catch (Exception e)
        {
            System.exit(0);//if exception occure..
        }
        finally
        {
            // code to be executed irrespective of the
occurrence of exception
        }
    }
 
Is This Answer Correct ?    0 Yes 0 No
K.k
[SEARCHIN FOR JOB]
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is non static block in java Ness-Technologies6
Which One is optimal to choose ? Syncronized hash map or Hash table with single thread model? How can a hash map syncronized with out using syncrozed blocks in programm? Four-soft3
what is the difference between HashMap and Hashtable Value-Labs8
What is the difference between java and .Net? Bosch5
types of applets?. TCS3
Can you call a constructor within a constructor?  6
Can you have a constructor in abstract class?  7
can we create instance for interface in java?  2
What is clipping?  2
how u do unit testing? iFlex2
What is inheritance?  4
how to handle http request in struts Polaris2
How many statements can be created with one connection in jdbc? Polaris2
How to access a method that it declared as protected?  3
I have a class which is abstract which contains only the abstract methods. This is similar to an interface. Then, if i have given a choice to choose one of them. Which one i have to choose and why?  4
what are the methods of an object class?  3
why java does not support mulitple inheritance directly? TCS2
What are the OOAD concepts in java explain with examples? Aricent4
AWT event listeners extends what interface?  1
can u give one sinario when you use Abstract Class and When you use Interface. ITC-Infotech5
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com