UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why is finally introduced in Java?

Asked by Last Modified  

21 Answers

Learn Java

Follow 0
Answer

Please enter your answer

Java Trainer

Finally is introduced in Java to do the code clean up or if you wants to perform some operation irrespective of whether the code throws an Exception or not.
Comments

Tutor

The finally block always executes, even if exceptions are not there. So, if you forget to write a requisite try or you want your program to end in a specified way, finally comes to play.
Comments

Java Trainer

end of the code executed.
Comments

Assuming that you mean "finally" that comes after try block: "finally" block is great place to free up resources, like DB connection, File etc. Finally is executed regardless of whether an exception occurs or not. Putting cleanup code in a finally block is always a good practice, even when no exceptions...
read more
Assuming that you mean "finally" that comes after try block: "finally" block is great place to free up resources, like DB connection, File etc. Finally is executed regardless of whether an exception occurs or not. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated. read less
Comments

Java Trainer with 6+ years of experience in big MNCs

finally is introduced to perform the cleanup operations such as closing the open DB connection clearing up the resources etc.
Comments

Java Web Application Development and Aptitude Trainer

Finally block helps you specify a block of code which you would want executed no matter if an exception arises or not.
Comments

Finally creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown. If an exception is thrown, the finally block will execute even if no catch statement matches...
read more
Finally creates a block of code that will be executed after a try/catch block has completed and before the code following the try/catch block. The finally block will execute whether or not an exception is thrown. If an exception is thrown, the finally block will execute even if no catch statement matches the exception. Besides exception handling, finally is also used in file closing and freeing up any other resources, when a method is about to return to the caller from inside try/catch block through a return statement and finally clause is executed just before methods returns. read less
Comments

Professional with 11 years of Java/J2EE SW development Industry experience.

Finally block in Java exception handling is a mechanism to write some clean-up activity code. Since 'finally' block code always executes it gives the programmer to do the clean-up activity even if the code in try block results in an unexpected exception. Also the finally code cannot be bypassed with...
read more
Finally block in Java exception handling is a mechanism to write some clean-up activity code. Since 'finally' block code always executes it gives the programmer to do the clean-up activity even if the code in try block results in an unexpected exception. Also the finally code cannot be bypassed with a 'break, return or continue'. Its a good practice to always include the finally block after try and catch. read less
Comments

Senior Software Engineer

it depends on whether you can deal with the exceptions that can be raised at this point or not. If you can handle the exceptions locally you should, and it is better to handle the error as close to where it is raised as possible. If you can't handle them locally then just having a try / finally block...
read more
it depends on whether you can deal with the exceptions that can be raised at this point or not. If you can handle the exceptions locally you should, and it is better to handle the error as close to where it is raised as possible. If you can't handle them locally then just having a try / finally block is perfectly reasonable - assuming there's some code you need to execute regardless of whether the method succeeded or not. read less
Comments

Senior Software Engineer

t depends on whether you can deal with the exceptions that can be raised at this point or not. If you can handle the exceptions locally you should, and it is better to handle the error as close to where it is raised as possible. If you can't handle them locally then just having a try / finally...
read more
t depends on whether you can deal with the exceptions that can be raised at this point or not. If you can handle the exceptions locally you should, and it is better to handle the error as close to where it is raised as possible. If you can't handle them locally then just having a try / finally block is perfectly reasonable - assuming there's some code you need to execute regardless of whether the method succeeded or not. read less
Comments

View 19 more Answers

Related Questions

What's Java's most used IDE?
As per Dzone's recent survey, The Eclipse IDE remains the most popular place for Java developers to primarily write their code, though it saw a 7% decrease from last year’s survey results (50% in 2016...
Ritu
0 0
7
What is difference between Multithreading and miltiprocessing?
It is simple to understand. You question itself contains the answer. Only the keynote is: A single processor/core of the cpu can execute single task at a time, not more than one task. And you should...
Milan
will I get certificate
Better than certificate if you enroll with me you will get confidence and lot of practical knowledge...certifications dont matter after a period of time what really matters is your approach to a problem...
Sk.
What is Constructor in Java?
1. Constructor is just like a method ( referred as special method as it appearance look like normal methods) 2. It's name is same as class name 3. It doesn't return any value 4. It is invoked/called...
Ujwalajagdale
0 0
8
What are the best books for learning programming languages like C (except let us C), Java, Python, etc.?
you can read "Head First Java",I do read it even now after having 6 years of working experience in Java when I want to refresh some concept. you can also read Core Java, Volume 1 and 2 by Cay S. Horstmann,...
Shashank
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Interview Tip : Q1) Why Strings are immutable in java ? What happen if it was mutable in java?
As we all know that Strings in java are immutabe in nature, now the question comes why the creator made it immutable in nature, although this field used maximum in any java program. The answer to this...

Introduction to Course Content
Video about what we are going to learn throughout the Java Training Session .

Java inheritance example
Answer these questions Answer the above question

TestNG Annotations and its sequence
public class TestNGAnnotations { @BeforeMethod public void beforeM() { System.out.println("Before Method"); } @AfterMethod public void afterMethod() { System.out.println("After Method"); } @BeforeClass...
S

Sarthak C.

0 0
0

Class and Objects in Java
Class is a template or a blueprint which is used to describe an object. On other hand Object is a reference of a class which follows all the stuff written inside the class. How about taking the whole tour in the following video

Recommended Articles

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more