UrbanPro
true

Learn Java Training from the Best Tutors

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

Search in

Final, Finally And Finalize In Java

Md Ajmat
16/01/2018 0 0

Final:

1. It is a non access modifier that can be applied to variables,methods and to class.

2. Final means non-changable.

 

Final variable:

1. If a variable is declared as final it can't be re-assigned.

2. If there is any final variable in class simply compiler replaces its original value to that variable at compile time only,hence at runtime direct the constant value participates.

3. Final variable should must be initialized at the declaration time.

4. Final variable doesn't get any default value by compile or jvm,the programmer needs to initialize.

 

Final Method:

1. If we are declaring method as final in class, that method can't be re-defined or override.

2. If parent class want that their child can't re-define the method then parent class can define the final method in their class.

 

Final Class:

1. If we are declaraing class as final, that class can't be inherited.

2. For example-String class is final and we can't extends the String class.

 

Finally:

1. Finally is the keyword that comes along with try.

2. To write the clean-up code we can place the finally block. for example-Database closing logic,Stream closing logic or any other resource closing logic which we have opened.

3. This block must be executed irrespective of the Exception in the code.

 

Finalize:

1. This is the method of Object class and is applicable for all java objects.

2. Before destroying the objects, jvm calls the Garbage Collector and Garbage collector implicitly calls the finalize() method to perform the cleanup activity.

0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Priority in TestNG
public class Priority { @Test (priority=1)public void login() {System.out.println("login");} @Testpublic void email1() {System.out.println("email1");} @Test (priority=-2)public void email2() {System.out.println("email2");} //I...
S

Sarthak C.

0 0
0

Java complete reference-herbert schildt
Sample program: class Sample { public static void main(String args ) { System.out.println("Sample") ; } } Program explanation: Keyword used in line 1- class The name...

Why Should We Learn Java Language?
Most of starters has confusion today that which of the programming language should be chosen to work on. It totally depends upon your need. As per my opinion, if you want to grow your career in IT industry...

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...

Android : Support multiple themes in an android application
If you are developing a theme based application to enhance user experience, then following steps needs to follow.We are taking example of an android application having 2 themes white and black.Step 1:Define...
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