Explain difference between final, finally and finalize?

Answer Posted / ranganathkini

When a class is marked final, it cannot be subclassed. When
a method is marked final, it cannot be overridden by the
subclass. And when a field is marked final, its value once
set, cannot be reset.

finally is the last clause in a try...catch block. It is a
block of statements that is executed irrespective if or if
not an exception was caught in the preceding try block.

finalize is a reserved method in Java, which can be
overridden by classes containing code to release any
expensive resources being held to by the object. Expensive
resources include, native peer objects, file/device/database
connections.

Is This Answer Correct ?    64 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can any body body expalin best definitions & best real time exaples for opps concepts.

2034


What happens if a constructor is declared private?

773


I want my class to be developed in such a way that no other class (even derived class) can create its objects. Define how can I do so?

901


What is meant by attribute?

772


How do you use spaces in java?

722


What is the independent variable in an experiment?

740


What is the main difference between java platform and other platforms?

700


What is the use of predicate in java 8?

680


Is array passed by reference in java?

784


What is a bufferedreader?

731


Can we use String with switch case?

850


What is a boolean structure?

775


Is there any way to find whether software installed in the system is registered by just providing the .exe file? I have tried the following code but its just displaying the directory structure in the registry. Here the code : package com.msi.intaller; import java.util.Iterator; import ca.beq.util.win32.registry.RegistryKey; import ca.beq.util.win32.registry.RootKey; public class RegistryFinder { public static void main(String... args) throws Exception { RegistryKey.initialize(RegistryFinder.class.getResource("jRe gistryKey.dll").getFile()); RegistryKey key = new RegistryKey(RootKey.HKLM, "Software\\ODBC"); for (Iterator subkeys = key.subkeys(); subkeys.hasNext();) { RegistryKey subkey = subkeys.next(); System.out.println(subkey.getName()); // You need to check here if there's anything which matches "Mozilla FireFox". } } }

1538


What is a class reference?

760


what is the significance of listiterator in java?

802