How can final class be used?

Answer Posted / user

One scenario where final is important, when you want to prevent inheritance of a class, for security reasons. This allows you to make sure that code you are running cannot be overridden by someone.

The best example is
public final class String

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I right-justify a string?

629


What is ternary operator?

570


What is a numeric string?

568


What is meant by binding in rmi?

552


Why is logger singleton?

564






What is use of inner class in java?

518


What does 3 dots mean in java?

524


Can we use switch statement with strings?

624


What is meant by vector class, dictionary class, hash table class, and property class?

687


Can a method be overloaded based on different return type but same argument type?

550


What is update method called?

667


What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

633


Explain about assignment statement?

601


What is getkey () in java?

581


What interface is extended by awt event listeners?

597