What is class variables and instance variables?

Showing Answers 1 - 12 of 12 Answers

shanthini

  • Nov 8th, 2005
 

class varible is the variable used in the class, ie class members.

instance variables are the class objects

  Was this answer useful?  Yes

Devidas Sonawane

  • Nov 8th, 2005
 

Class variable are class member which are used in the class and instance variable is a object of that class to be used to access methods of that class.

  Was this answer useful?  Yes

Vinay

  • Nov 13th, 2005
 

Class variables are in class scope and instance variable in object scope.we can access class variables with class name as well as object reference where as instance variable can be accessed only by instances(objects)

  Was this answer useful?  Yes

SailajaT

  • Nov 15th, 2005
 

Class variables are member variables of a class but are declared as static. Instance variables are member variables of class which are not declared as static. Instance variables belong to object only where as class variables are shared by all the objects of the corresponding class.

  Was this answer useful?  Yes

justAnother

  • Nov 15th, 2005
 

In addtion to the above:

Class variables are one per class where as instance variables are one per instance of the class (object).

Class variables are static variables.

Class variables can be accessed before creating any instance (object) of the class.

Class variables cannot be declared inside instance methods.

  Was this answer useful?  Yes

Prabin

  • Dec 31st, 2005
 

class variables are the variables declared in a class itself. The instance variables are the variables asociated with the object. When we calling a function by passing an object then the variables associated with the object is accesible ,these variables are called as instance variable in that function(ie variables at that Perticular Instance)

  Was this answer useful?  Yes

Tafazzul hasan

  • Feb 21st, 2007
 


Class variables belongs to a Class
where as an instance variable belongs to an Object.

 A class variable is shared by all the objects of the class.
 where as every object contain their own instance variable.

  Was this answer useful?  Yes

Class variable:? 1. Also called as static variable.
2. Variable declared?in the class with static modifier.
3. These variables are belong to the class.

Instance variable:? 1. Variables declared in the class?without?the static modifier.
2. These variables are belongs to the objects.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions