29. Talk about final keyword in Java?

Talk about final keyword in Java?

  • Final keyword in Java is used to restrict user action
  • With final keywords, we have final variable, final method and final class
  • Final variable: In Java, a final variable is declared with final keyword and then you won’t be able to change that variable. Or in a simple word, it’s constant
  • Final method: A final method is declared with final keyword so that subclass will not be able to overridde that method
  • Final class: when a class is declared with final keyword, it can not be inherited

Leave a Reply

Your email address will not be published. Required fields are marked *