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
58 views

2 answers to this question.

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,050 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,050 points
937 views
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
89 views
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
62 views
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,540 points
206 views
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
85 views
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,810 points
132 views
+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,380 points

edited Nov 6, 2018 by Omkar 11,501 views
0 votes
2 answers

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

@Override annotation is used when we override ...READ MORE

answered Aug 14 in Java by Sirajul
• 41,000 points
137 views
0 votes
2 answers

What is the difference between Set and List in java?

LIST SET Duplicates YES NO Order Ordered Depends on Implementation Positional Access YES NO List is an ordered sequence ...READ MORE

answered Aug 14 in Java by Sirajul
• 41,000 points
174 views