The correct answer is D. Static constant.
A static constant is a variable that is declared with the static
keyword and the final
keyword. It is initialized once, at compile time, and its value cannot be changed after it has been initialized.
A constant variable is a variable that is declared with the final
keyword. It can be initialized at compile time or at runtime.
A class variable is a variable that is declared inside a class but outside of any methods or constructors. It is shared by all instances of the class.
A named constant is a variable that is declared with the const
keyword. It is similar to a static constant, but it can only be used in the file in which it is declared.
Here is an example of a static constant:
“`
public class MyClass {
private static final int CONSTANT = 10;
public static void main(String[] args) {
System.out.println(CONSTANT); // prints 10
}
}
“`
In this example, the CONSTANT
variable is a static constant. It is initialized to the value 10 at compile time, and its value cannot be changed after it has been initialized.