हिंदी

Explain the various types of Variables in JAVA.

Advertisements

प्रश्न

Explain the various types of Variables in JAVA.

स्पष्ट कीजिए
Advertisements

उत्तर

  1. Local Variables: Local variables are declared inside a method, constructor or block. They can be accessed only within the block in which they are declared. These variables must be initialized before use.
  2. Instance Variables: Instance variables are declared inside a class but outside any method, constructor or block. Each object of the class has its own copy of these variables. Their values may differ from one object to another.
  3. Static Variables (Class Variables): Static variables are declared inside a class but outside any method or constructor using the static keyword. These variables are shared by all objects of the class, and only one copy exists for the entire class.
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
अध्याय 6 Variables and Expressions
EXERCISE | Q 9. | पृष्ठ १३१
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×