Fiveable
Fiveable

Static

Definition

In programming, "static" refers to a variable or method that belongs to the class itself, rather than an instance of the class. It can be accessed without creating an object of the class.

Analogy

Think of a static TV channel that you can watch without having to turn on your television. Similarly, a static variable or method is always available and doesn't require an instance of the class.

Related terms

Instance Variable: A variable that belongs to each individual object created from a class.

Class Method: A method that belongs to the class itself and can be called without creating an object.

Static Block: A block of code in a class that is executed only once when the class is loaded into memory.

"Static" appears in:

Practice Questions (3)

  • Which keyword is used to declare a variable or method as static in Java?
  • Which of the following can be declared as static?
  • Which of the following lines of code properly declare a private static variable called "name"?


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.