1.

Final keyword in Java and different contexts

Answer»

Final KEYWORD in JAVA and different contexts
Final is one of the special keyword used in Java and that is used as a non-access MODIFIERS. Below are the different contexts which is used Final keyword:-

(1)Final Variable:-Once we used final keyword with variable we cannot change its value once we assigned. If no values is assigned to the final keyword then by using the class constructor a value can be assigned to it.

(2)Final METHOD:-When we declare method as final then it cannot be overridden by the inheriting class.

(3)Final class:-When a class is declared as final in java then it cannot be extended by any subclass class but it can extend other class.



Discussion

No Comment Found