Author Topic: Difference between final,finally and finalize in Java  (Read 744 times)

0 Members and 1 Guest are viewing this topic.

Offline vinayaksharma28

  • College Representatives
  • Full Member
  • *
  • Points: 320
  • Posts: 203
  • The only way to do great work is to love what u do

    • MSIT
    • _
      CSE
    • View Profile
Difference between final,finally and finalize in Java
« on: December 04, 2014, 04:37:46 pm »
This is the most asked question in viva and exams according  to my experience ...... and and most confusing question too for those who are new to Java .. so here i am sharing the basic difference between them

final: final is a keyword. The variable decleared as final should be initialized only once and cannot be changed. Java classes declared as final cannot be extended. Methods declared as final cannot be overridden.

finally: finally is a block. The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling - it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.

finalize: finalize is a method. Before an object is garbage collected, the runtime system calls its finalize() method. You can write system resources release code in finalize() method before getting garbage collected.
You do not have permission to give points
point 15 Points

Users who gave points in this topic » EZIO (10 Pts) » gurudubey (5 Pts) 

 

Difference Between Draft Lokpal Bill and Jan Lokpal Bill

Started by techmaniac

Replies: 0
Views: 3438
Last post April 08, 2011, 02:37:05 pm
by techmaniac
Difference between bluetooth 2.0 and bluetooth 2.1

Started by Shankynayak

Replies: 1
Views: 2027
Last post August 18, 2012, 12:19:49 pm
by RamakantPareek
Difference Between Fraunhofer Diffraction And Fresnel Diffraction

Started by XYLS

Replies: 1
Views: 3786
Last post January 06, 2014, 05:23:53 pm
by ranjan82
What is the difference b/w morning shift and evening shift

Started by BEN TENNYSON

Replies: 6
Views: 5134
Last post May 09, 2013, 10:13:03 pm
by Champ
Difference Between Nokia 920, Samsung Galaxy S3 And Apple iPhone 5

Started by XYLS

Replies: 2
Views: 2291
Last post January 06, 2014, 05:18:58 pm
by ranjan82
Sitemap 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49