1/8/25, 11:01 PM Difference between Static and Final Variable in Java
Download the BYJU'S Exam Prep App for free GATE/ESE preparation videos & tests - Download the BYJU'S Exam Prep App fo
DOWNLOAD NOW (http://bit.ly/3i8IueA) ×
BYJU'S GATE (/gate/) > GATE (/gate/gate-exam/) > Difference Between (/gate/difference-between-in-gate/) > Difference Between Static and Final Variable in Java (/gate/difference-
between-static-and-final-variable-in-java/)
(tel:+919241333666)
Difference between Static and Final Variable in Java
Static and final are two important keywords that belong to object-oriented programming languages like Java. The static keyword is used to
represent the class member. It is basically used with methods and variables to indicate that it is a part of the class, not the object. On the other
hand, the final keyword is used to proclaim a constant variable and to bind the user from accessing a method, variable, or class. Let’s figure out
some major differences between static and final keywords in Java.
What is Static Variable in Java?
A variable with the static keyword is known as a static variable in Java. These variables are generally referred to as the common belongings of a
group of objects. These variables help in saving a lot of memory and getting the memory at the time of loading the class.
What is Final Variable in Java?
When a variable is expressed with the final keyword, then it is not possible to change its value. Yes, in Java, we can use the final keyword with
methods, variables and classes. When the final keyword is utilised with a variable of primitive data types, we cannot modify the value.
Difference between Static and Final Variable in Java
S.N Static Variable Final Variable
o.
1 The static keyword is connected to occupied static classes, variables, The final keyword is connected to class, variables and
methods and blocks. methods.
2 Here, it is not mandatory to initialise the static variable while declaring it.. Here, it is mandatory to initialise the final variable while
declaring it.
3 They can be reinitialized. We can not reinitialize the final keyword.
4 They can only access the static members of the class, and only static They cannot be inherited.
methods can call them.
5 The object of the static class cannot be created, and holds only static It is not possible to inherit the final class from any class.
members.
6 Static block is used to initialise the static variables. Final keyword does not support such a block.
Keep learning and stay tuned to BYJU’S to get the latest updates on GATE Exam (https://byjus.com/gate/gate-exam/) along with GATE Eligibility
Criteria (https://byjus.com/gate/gate-eligibility-criteria/), GATE 2024 (https://byjus.com/gate/), GATE Admit Card (https://byjus.com/gate/gate-
admit-card/), GATE Application Form (https://byjus.com/gate/gate-application-form/), GATE Syllabus (https://byjus.com/gate/gate-
syllabus/), GATE Cutoff (https://byjus.com/gate/gate-cutoff/), GATE Previous Year Question Paper (https://byjus.com/gate/previous-year-
question-papers/), and more.
https://byjus.com/gate/difference-between-static-and-final-variable-in-java/ 1/7