हिंदी

State any one difference between instance variable and class variable. - Computer Science (Theory)

Advertisements
Advertisements

प्रश्न

State any one difference between instance variable and class variable.

Differentiate between instance variable and class variable. 

अंतर स्पष्ट करें

उत्तर १

  1. Each instance variable is created separately, but class variables are created once and shared by all class objects.
  2. Instance variables are defined without the static keyword, whereas class variables are declared with the static keyword in a class.  
shaalaa.com

उत्तर २

S. No. Instance variable Class variable
1. Instance variables are defined without the 'static' keyword.

Class variables are defined using the Keyword 'static'.

2. Instance variables are separate copies of an object. A static variable (class variable) will be accessible as a singular shared instance for all class instances.
shaalaa.com
Object as an Instance of a Class
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Class as the Basis of all Computation (Objects and Classes) - EXERCISES [पृष्ठ ३८४]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 6 Class as the Basis of all Computation (Objects and Classes)
EXERCISES | Q V. 7. | पृष्ठ ३८४
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×