Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How does final modifier work?

Answer Posted / javamasque

Final in java is used to restrict user to change further. It is used in various context as below

Final variable
• As variable become final, its value will never be modified.
• The variables become read only variable forever.
• If final variable is static then it must be initialized at the time of declaration.
• A non-static final variable can be blank but must be initialized in constructor.
• A local variable can be final.
• Final variables usually come with static key word as constant.

Final method
• As method become final, it never be override but be overload.
• A final method can be static and synchronized but never be abstract.
• As we are sure that the method implementation is complete and will never be override then we should make it final.

Final class
• A final class is complete class and will never be sub-classed.
• Final class helps to define immutable class.
• There are some final classes like String, Integer and other wrapper classes.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are daemon Threads in java?

1200


Does java allow default arguments?

996


What is the function of static in java?

1073


What is anonymous inner class?

1083


Explain thread in java?

1163


What is finally in Java?

1079


What are different data types?

1022


What is qms certification?

953


What is synchronization and why is it important in java programming?

940


what is object slice?

2084


What happens if we don’t define serial version uid?

1028


What is final keyword in java? Give an example.

1016


What is the difference between throw and throws in java?

1098


What is busy spin, and why should you use it?

1083


I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?

1101