Explain final, finalize() and finally?
Answer Posted / 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 |
Post New Answer View All Answers
How can we access some class in another class in java?
What is serialversionuid?
What is the difference between a local variable and an instance variable?
How do you bind variables?
Can we assign integer value to char in java?
What is main difference between variable and constant?
How can we make string upper case or lower case?
List any five features of java?
What are scriptlets?
How to set the permissions to a file in java?
What is singleton class in ruby?
How do you initialize an arraylist in java?
How many bits is a boolean?
What is a predicate method?
For ease of programming you can consider the maze as a 2D array with colors represented by below integer and characters (in capital letters). • B - Black • W -White • G- Green • R- Red R B W B W W W W W W B W B B W W W W W W W B W B W W W B W W W W B B W W W B W W W B W W B B B B W B W B W W B W W W B W W W B B B W W B W W W B W W B W B W W W B W B W W W W B B W W W W B W W W W W G Shortest Route Problem: • Solution that finds the shortest Route between Red and Green White will have 1 Weight. Red and Green carry no weights. Shortest path is the path with less weight when you add up the weights in the path.