[amp_mcq option1=”dynamic” option2=”unary” option3=”static” option4=”volatile” correct=”option3″]
The correct answer is C. static.
A static variable is a variable that is associated with a class, not with an instance of a class. This means that there is only one copy of the variable, no matter how many objects are instantiated from the class.
A dynamic variable is a variable that is created on the heap, and its lifetime is managed by the garbage collector.
A unary operator is an operator that takes one operand.
A volatile variable is a variable whose value can be changed by code outside of the current thread.
Here is an example of a static variable:
“`class MyClass {
static int x;
public MyClass() {
x = 10;
}
}
“`
In this example, the variable x is a static variable. This means that there is only one copy of the variable, no matter how many objects are instantiated from the class MyClass. The value of x will be 10 for all objects of the class MyClass.