[amp_mcq option1=”Private” option2=”Public” option3=”Dim” option4=”Static” correct=”option1″]
The correct answer is: Static
A class-level variable is a variable that is declared inside a class but outside of any methods or properties. It is accessible to all methods and properties in the class, and its value is shared by all instances of the class.
A class-level variable is declared using the static keyword. For example:
“`class MyClass
{
static int myVar;
public void MyMethod()
{
Console.WriteLine(myVar);
}
}
“`
In this example, myVar is a class-level variable. It can be accessed from any method in the MyClass class, and its value is shared by all instances of the class.
The other options are incorrect because:
Privateis a keyword used to declare a variable that is only accessible to members of the class in which it is declared.Publicis a keyword used to declare a variable that is accessible to all code in the program.Dimis a keyword used to declare a variable in Visual Basic.
I hope this helps! Let me know if you have any other questions.