GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 60 of 923    Print  
What is the purpose of the finally clause of a try-catch-finally statement
The finally clause is used to provide the capability to execute code no matter whether ornot an exception is thrown or caught.


  
Total Answers and Comments: 2 Last Update: April 11, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
September 15, 2005 15:03:46   #1  
anubhav        

RE: What is the purpose of the finally clause of a try...
yes basic purpose of finally clause is same but it is not always true it will execute every time specially when there is System.exit either in try or catch clause dealing with try clause exception
 
Is this answer useful? Yes | No
April 11, 2008 12:57:24   #2  
ashoksurati Member Since: April 2008   Contribution: 13    

RE: What is the purpose of the finally clause of a try-catch-finally statement
In try,catch clauses either try clause(If exception is not happend) or catch clause(If exception occures) is exicuted.If we want to exicute a block of statements doesn't depend on exception then we put those block of statements in finally block.

i.e finally block execution doesn't depend on the exception.If exception doesn't occur then "try ,finally " clauses other wise "catch  , finally" will be exicuted.

ThankU
Ashok

 
Is this answer useful? Yes | No

 Related Questions

A package statement must appear as the first line in a source code file (excluding blanklines and comments). 
Latest Answer : package statement must appear as the first line in a source code file and one public class declaration. ...

Yes, a for statement can loop indefinitely. For example, consider the following:for(;;) ; 
Latest Answer : The for loop will be working fine even without the initialization.Hence for(;;) will create a indefinite loop. ...

If a checked exception may be thrown within the body of a method, the method musteither catch the exception or declare it in its throws clause. 
Latest Answer : this rule is actually for handling the exceptions:that is there are two ways by ehich u can handle the exception :1:either you use the try catch statement and enclose the appropriate code in the try catch block,this is called as the catch or the HANDLE ...

The purpose of finalization is to give an unreachable object the opportunity to performany cleanup processing before the object is garbage collected. 
Latest Answer : Java provides a method called finalize( ) that you can define for your class. Here’s how it’s supposed to work. When the garbage collector is ready to release the storage used for your object, it will first call finalize( ), and only on the next garbage-collection ...

The purpose of the Runtime class is to provide access to the Java runtime system. 
Latest Answer : Which returns the runtime information like memory availablilityRuntime.freeMemory() --> Returns JVM Free MemoryRuntime.maxMemory() --> Returns the maximum amount of memory that the JVM will attempt to use.also helps to run the garbage collectorRuntime.gc() ...

The finally clause is used to provide the capability to execute code no matter whether ornot an exception is thrown or caught. 
Latest Answer : In try,catch clauses either try clause(If exception is not happend) or catch clause(If exception occures) is exicuted.If we want to exicute a block of statements doesn't depend on exception then we put those block of statements in finally ...

A break statement results in the termination of the statement to which it applies (switch,for, do, or while). A continue statement is used to end the current loop iteration andreturn control to the loop 
Latest Answer : The break keyword halts the execution of the current loop and forces control out of the loop. The continue is similar to break, except that instead of halting the execution of the loop, it starts the next iteration. ...

It must provide all of the methods in the interface and identify the interface in itsimplements clause. 
Latest Answer : interface enhance the concepts of inheritence. by calling multiple interfaces to class we can also inherinting more than a class indirectly ...

Commas are used to separate multiple statements within the initialization and iterationparts of a for statement. 

The wait(),notify(), and notifyAll() methods are used to provide an efficient way forthreads to wait for a shared resource. When a thread executes an object's wait() method, itenters the waiting state. 
Latest Answer : wait() will move the thread to sleep state allowing for the other thread to execute. notify() will trigger back the wait() thread to ready state and to execute further. notifyAll() will trigger all wait() threads to ready state. Later, it will ...


 Sponsored Links

 
Related Articles

Service Oriented Java Business Integration Review

Service Oriented Java Business Integration Review Introduction If you ve read through the texts which give you an introduction to SOA or Web Services you will often find them to be quite frustrating and the reason for this is because they spend too much time referencing business processes which are
 

Java and Client Server Models

Java and Client Server Models The Role of Client Servers on the Web Client server models provide the essential mechanisms for working with the Internet In fact most of the World Wide Web is built according to this paradigm In client server models the web browsers run by millions of users are the cli
 

What are the limitations with switch statement?

Switch statement is a powerful statement used to handle many alternatives and provides good presentation for C program. But there are some limitations with switch statement which are given below: Logical operators cannot be used with switch statement. For instance case k>=20: is not allowe
 

goto Statement

Why to avoid goto in C C has goto statement but one must ensure not to use too much of goto statement in their program because its functionality is limited and it is only recommended as a last resort if structured solutions are much more complicated. First let us understand the goto statement, its
 

The Interview Snafu

How to turn someone else’s mistake to your advantage Your dream job is about to become reality. A recruiter gave you the heads up about the perfect position at Humungous Conglomerate, Inc. You went through five interviews as well as a battery of psychological tests mandated by their HR de
 

Winning a Job Interview with a Winning Resume

Does your resume unlock your potential, take your skills to the highest level and win you the interview and the job you want now? The job market today is highly competitive and even if you think you have what it takes to get an interview you won’t get over the line without a polished, prof
 

Using UML with Java

Using UML with Java While Java is not a new language its application for the development of embedded systems is quite new Developers are beginning to take a second look at modeling languages such as UML and many feel it can be a powerful tool in their development arsenal mosgoogle center Introductio
 

Importance of Proper English during Job Interview

Importance of Proper English during Job Interview Your job interview is crucially important and it will determine whether or not you will get the job Depending on the type of job you re going for it is very important for you to use proper English In most cases jobs which offer higher salaries will h
 

Java Technology Trends

Technology Trends Involving Java Java is an object oriented programming language OOP for Web browsers It is organized around data rather than actions and supports polymorphism which allows the same code to be written generically so it can function with different datatypes inheritance which allows on
 

HR Interview - HR Interview Mistakes You Will Want To Avoid

HR Interview Mistakes You Will Want To Avoid The job interview can be a stressful process This is especially true for those who are going after a competitive position Your nonverbal communication combined with the answers you give during the interview will determine if you are hired mosgoogle While
 

Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape