Single Choice Easy

QWhat is a static variable in Java?

ID: #10345 Abstract class and method 182 views
Question Info
#10345Q ID
EasyDifficulty
Abstract class and methodTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A A static variable is a variable that is accessible only within the static methods of a class.
  • B A static variable is a variable that is shared among all instances of a class and is not specific to any particular instance.
  • C A static variable is a variable that is declared with the "static" keyword and cannot be changed once assigned a value.
  • D A static variable is a variable that is declared inside a static block in a class.
Correct Answer

Explanation

A static variable in Java is a variable that is declared with the "static" keyword and cannot be changed once assigned a value. It is accessible from anywhere within the class, but not from outside the class. It is also shared among all instances of a class, meaning that any changes made to the static variable will be reflected in all instances of the class.

Share This Question

Challenge a friend or share with your study group.