What does the "final" keyword mean in front of a variable? A method? A class?

FINAL for a variable : value is constantFINAL for a method : cannot be overriddenFINAL for a class : cannot be derived

Showing Answers 1 - 1 of 1 Answers

Final when written in front of a variable it means that the value assigned to that variable is constant.It is similar to const keyword as in C.

eg final int a=8;

This means that variable a ,through out the program will hav value of 8.

when written in front of method its mean that this method cannot be overwritten

when written in front of class it means that this class is final and cannot be inherited.eg string class is a final class

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions