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

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,120 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,120 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,290 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,620 points
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
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
+5 votes
4 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,450 points

edited Nov 7, 2018 by Omkar 74,626 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
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
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP