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

What is hasnext in java?

568


What is java and their uses?

542


What is the biggest integer?

537


Can you explain inner class.

579


Why static functions are used?

557






How do you access command-line arguments within the code?

563


How do you replace a string in java?

533


Why is a constant variable important?

488


Can a set contain duplicates?

509


Can you give names of Container classes?

1842


what is encapsulation in java? Explain

655


How many ways can an argument be passed to a subroutine and explain them?

564


What is string in java? String is a data type?

568


Is treeset sorted in java?

570


What is use of super keyword in java?

584