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

Between Java and Python, which one is better to learn first and why?
Both the development programs come with their strong suits. While Java allows you to enjoy the cross-platform support, Python helps you execute on at least ten different operating systems. It would help...
Priyanka
0 0
5
How does Java implement polymorphism?
Java implements polymorphism in two ways: 1. Static or compile-time polymorphism is done by method overloading (more then one methods sharing the same name but different number/types/order of parameters) 2....
Sajjan
0 0
6
What is the difference between string, stringbuffer, stringbuilder?
String is immutable, means once you created a String you can not modify, Even if you try to it will create a new string for you and assign that to you. StringBuffer and StringBuilder are immutable, however...
Neha
Which is a good Java training and placement institute for a fresher in Bangalore?
I know an institute in HYderabad which is giving 100% job guarantee or 100% fee refund. They have office in bangalore also, not sure whether they are offering this program in Bangalore. Please visit their...
Raja
0 0
5

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

Ask a Question

Related Lessons

Finding a Majority Element
Problem Description Task. The goal in this code problem is to check whether an input sequence contains a majority element. Input Format. The first line contains an integer, the next one contains a sequence...

Java Hash Map internal implementation
1.Hash Map internal implementation: In hash map it will create an array of table (to store the {Key,Value} pair) which is of type java.util.HashMap.EntryThe Entry object contains {hash, key, next, value}...
R

Implementation: What Is JPA And JPA?
The basic Java framework to access the database is JDBC. Unfortunately, with JDBC, a lot of hand work is needed to convert a database query result into Java classes. JPA allows us to work with Java classes...

4 Things Every Tech Startup Needs to Know About The Coaching Industry
Knowledge on any subject is widely available to those who wish to learn. However, just gathering knowledge from other people doesn’t guarantee results in business. Results come from applying what...

Migration from other languages to Salesforce
Anyone can easily migrate from other language to Salesforce. People must have skills to understand business logic.

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