What is the purpose of final keyword and when to use it?



What is the purpose of final keyword and when to use it?..

Answer / Neetu Gangwar

"The 'final' keyword in Java has several uses: A variable declared as final can only be assigned once, a method cannot override a final method, and a class declared as final cannot be subclassed. It is used to ensure that a particular object or value remains constant throughout the program's execution. For example, final variables should be initialized at their declaration, and a final class signifies that it is immutable."

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can we catch more than one exception in a single catch block?

1 Answers  


Is java is a fully object object oriented language?

31 Answers   TCS,


What is a native method in java programming?

1 Answers  


Which is fastest collection in java?

1 Answers  


java is pure object-oriented programming language?why it is platform independent.

1 Answers  


What is the maximum size of arraylist in java?

1 Answers  


Can we declare an interface as final?

1 Answers  


what is overloading in java?

13 Answers   Ascent, DNS, Infosys, SDA, VelTech,


How many bytes is a string java?

1 Answers  


Can we have return statement in finally clause? What will happen?

1 Answers  


Is it possible to compare various strings with the help of == operator? What are the risks involved?

1 Answers  


What are the legal parameters?

1 Answers  


Categories