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,290 points
1,922 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,190 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,140 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,140 points
4,129 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
820 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,290 points
877 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,620 points
1,630 views
0 votes
1 answer

Why Java String class is declared as final?

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

answered Aug 22, 2018 in Java by code.reaper12
• 3,500 points
6,782 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,830 points
1,818 views
0 votes
1 answer

Final Keyword in Java

In Java, the final keyword is used ...READ MORE

answered Oct 17, 2023 in Java by Ayush
529 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, 2019 in Java by Sirajul
• 59,230 points
3,493 views
0 votes
2 answers

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,190 points
63,386 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP