Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


Explain final, finalize() and finally?

Answers were Sorted based on User's Feedback



Explain final, finalize() and finally?..

Answer / guest

we can declare final for class ,method,varible.
final varibles are unchangeble.
final classes are not subclassed.
final methods are not overriden.
finilize()
to clean up memory resourses for object using finilize().
finally block is executed if exception thrown or not.

Is This Answer Correct ?    100 Yes 9 No

Explain final, finalize() and finally?..

Answer / janet

final: final key word can be used for class,method and
variables.
A final class cannot be subclassed and it prevents other
programmers from subclassing a secure class to invoke
insecure methods.
A final method can't be overridden.
A final variable can't change from it's initialize value.

finalize(): finalize() method is used just before an object
is destroyed and can be called just prior to garbage
collection.

finally: finally, a key word used in exception
handling,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.
For example , if a method opens a file upon exit,then
you will not want the code that closes the file to be
bypassed by the exception-handling mechanism. This finally
keyword is designed to address this contingency.

Is This Answer Correct ?    63 Yes 4 No

Explain final, finalize() and finally?..

Answer / santhosi

final : final keyword can be used for class, method and
variables.
A final class cannot be subclassed and it prevents other
programmers from subclassing a secure class to invoke
insecure methods.
A final method can' t be overridden
A final variable can't change from its initialized value.

finalize( ) : finalize( ) method is used just before an
object is destroyed and can be called just prior to
garbage collection.
finally : finally, a key word used in exception handling,
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.
For example, if a method opens a file upon exit, then you
will not want the code that closes the file
to be bypassed by the exception-handling mechanism. This
finally keyword is designed to address this
contingency.

Is This Answer Correct ?    18 Yes 6 No

Explain final, finalize() and finally?..

Answer / venkataramana

final is a keyword.
we can use the final keyword in different context.
final keyword can be used with 1.Variables
2.Methods
3.Classes

When we use the final keyword with variables ,the value of
the final variable will not be changed i.e its value will be
fixed .

when we use the final keyword with methods, that is the
final method cannot be overridden.

when we use the final keyword with classes, that is the
final class cannot be extended to subclasses.

Finally() block is followed after try() or catch() block.
Finall() block executed even though if there the exception
having or not in the program.

Is This Answer Correct ?    8 Yes 1 No

Explain final, finalize() and finally?..

Answer / vijay chaudhary

Finally is used with try catch for Exception handling
purposes. Whatever written in Finally will run except if
program exits abnormally.
a Try should have atleast one catch or finally.

Is This Answer Correct ?    23 Yes 17 No

Explain final, finalize() and finally?..

Answer / tarun

Any class declared by final cannot be subclassed.

Any variable declared with final its value remain constant
that is declared at the time of declaring it.

Any method declared with final in a class can not be
override with other class.

finalize() method is called by the Garbage Collector on an
object when there is no more reference to the object.

finally method is used in exception handling with try-catch
block. try block can not be used alone, it should be used at
least with catch or finally. In catch block we catch(handle)
the exception type that occured during the execution and in
finally we write some code like closing file, connection,
garbag collect any object that is of no more useful in our
application.

Is This Answer Correct ?    7 Yes 2 No

Explain final, finalize() and finally?..

Answer / dwr

final varibles are unchangeble.
final classes are not subclassed.
final methods are not overriden.
finilize()
to clean up memory resourses for object using finilize().
finally block is executed if exception thrown or not.

Is This Answer Correct ?    7 Yes 2 No

Explain final, finalize() and finally?..

Answer / zama

final keyword are assigned to 3 different things such as
(1)___to variables:
if the variable is declared as final then value to
that variable can be assigned only once.
(2)___to methods:
if the method is declared as final then method cannot
be overridden.
(3)___to class:
if class is declared as final then class cannot be
inherited.



if finally block is defined in the main() then the stmt
under it will be executed surely,but if the stmt
System.exit(0); is before finally block then it is not executed.



finalize():
finalize() method is called by the Garbage
Collector on an object when there is no more reference to
the object.
finalize() is never run more than once on any object.

Is This Answer Correct ?    5 Yes 2 No

Explain final, finalize() and finally?..

Answer / radhika

Final keyword can be used for class, method and variables.
Afinal method can't be overriden.
Finalize() is used just before an object is destroyed or
garbage collected.
Finally keyword used in Exception handling, creates a block
of code that will be exceuted after a try and catch block.

Is This Answer Correct ?    1 Yes 1 No

Explain final, finalize() and finally?..

Answer / sunil

final variable is a constant.
final method cann't be overrid.
final class cann't be subclassed.

finally is a block usually used to release all the
resources utilized inside the try block such as to free
resources like stream objects, to close sockets .The code
in finally block is guaranteed of execution
irrespective of occurrence of exception catched/uncatched.

finalize() is never run more than once on any object.
finalize method is called by the garbage collector on an
object when the garbage collector determines that there are
no more references to the object.

Is This Answer Correct ?    4 Yes 11 No

Post New Answer



More Core Java Interview Questions

can we take more than one null values for Unique constraints.

1 Answers   3i Infotech,


What is a method in programming?

0 Answers  


What is difference between static variable and global variable?

0 Answers  


What is the difference between access specifiers and access modifiers in java? 16

0 Answers  


What is null in java?

0 Answers  






why top level class could not be static

2 Answers   L&T,


What is difference between char array and string?

0 Answers  


What is the size of int?

0 Answers  


Which is better stringbuffer or stringbuilder?

0 Answers  


What loop means?

0 Answers  


What access modifiers can be used for variables?

0 Answers  


Is string thread safe in java?

0 Answers  






Categories