+ 6

Is quiz in JAVA Challenge right?

I faced a quiz in JAVA Challenge "Finalized methods cannot be overriden", and the answer surprisingly was "false". Is that the right answer, and why? Thank you!

1st Apr 2019, 11:11 AM
William
William - avatar
7 Answers
+ 7
That is because what you do when you override a method is to reallocate a new function to a specific method, exactly what the final keyword prevents.
1st Apr 2019, 12:09 PM
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬
šŸ‘‘ Prometheus šŸ‡øšŸ‡¬ - avatar
+ 6
A finalĀ methodĀ cannot beĀ overriddenĀ or hidden by subclasses. https://en.m.wikipedia.org/wiki/Final_(Java)
1st Apr 2019, 11:56 AM
Tibor Santa
Tibor Santa - avatar
+ 6
The wording is very important here. Final method is not the same as finalize method. "TheĀ java.lang.Object.finalize()Ā is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup." So yes, it can be overridden. https://www.tutorialspoint.com/java/lang/object_finalize.htm
2nd Apr 2019, 5:00 AM
Tibor Santa
Tibor Santa - avatar
+ 2
Thank you, friends! I also think that finalized methods cannot be overriden. BUT!!! It was JAVA Challenge quiz and the answer was "false" in stead of "true". You can visit my profile on Sololearn and see screenshot of that quiz.
2nd Apr 2019, 12:52 AM
William
William - avatar
+ 2
Good point zemiak ,thanks for highlighting!
3rd Apr 2019, 3:56 AM
Tibor Santa
Tibor Santa - avatar
+ 1
Tibor Santa Oh my God! Thank you so much! I was overheating my brains for couple of days because of this. Great answer!
2nd Apr 2019, 5:51 AM
William
William - avatar
3rd Apr 2019, 3:39 AM
zemiak