Difference between Static and Final Variable in Java
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
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)
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.
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.
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