What is the use of final class in java?

0 votes
Actually I am new to programming, so I wonder if programmers actually use this on their program.
Jun 14, 2018 in Java by scarlett
• 1,280 points

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

The final keyword is used to restrict the user.

A final class can be used when you intend not to extend the class. For example, let's say there is a class "password", and you want that nobody can extend that class in your project. In this case, make your class FINAL. If you or somebody else want to extend that class in future then it shouldn't be FINAL.
But this analysis should be done long before writing code; because you can't go back and make it extensible once you mark it as FINAL.

answered Jun 14, 2018 by Akrati
• 3,150 points
0 votes

In Java, items with the final modifier cannot be changed!

This includes final classes, final variables, and final methods:

  • A final class cannot be extended by any other class
  • A final variable cannot be reassigned another value
  • A final method cannot be overridden
answered Oct 5, 2018 by Daisy
• 8,020 points

Related Questions In Java

0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,020 points
0 votes
1 answer

What is the use of StringBuilder in java?

If you use String concatenation in a ...READ MORE

answered Jun 19, 2018 in Java by Akrati
• 960 points
0 votes
1 answer

What is the use of assert keyword in java?

Java assertion feature allows the developer to ...READ MORE

answered Jun 28, 2018 in Java by scarlett
• 1,280 points
0 votes
1 answer

What is the concept of Immutability for strings in Java ? Why are strings immutable ?

According to Effective Java, chapter 4, page 73, ...READ MORE

answered May 11, 2018 in Java by Rishabh
• 3,520 points
0 votes
1 answer

Why Java String class is declared as final?

String class is made final in Java ...READ MORE

answered Aug 21, 2018 in Java by code.reaper12
• 3,450 points
0 votes
1 answer
0 votes
1 answer

What is blank final variable?

A final variable in Java can be ...READ MORE

answered Nov 29, 2018 in Java by Frankie
• 9,570 points
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,360 points

edited Nov 6, 2018 by Omkar 4,557 views
0 votes
1 answer

What is the use of @Override annotation in Java ? When do we use it ?

I think it is most useful as ...READ MORE

answered May 4, 2018 in Java by Akrati
• 3,150 points
0 votes
1 answer

What is the difference between Set and List in java?

List is an ordered sequence of elements. ...READ MORE

answered Apr 26, 2018 in Java by Akrati
• 3,150 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.