Static int a; // Class Variables
Student abc = new Student(); // Reference Variables
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 5, 2015, 6:48 AM EST
In contrast, instance variables apply to a particular instance and so each instance has its own copy which persists until the instance is garbage collected.
From outside the class and provided they are accessible, class variables are always accessed by prefixing them with the class name whereas instance variables are accessed through a reference to the instance in question.
Brijesh Gajjar48 reputationPosted Feb 5, 2015, 6:50 AM EST
Student abc = new Student(); is a object variable or reference variables ?
VulpesRank #55 · 29.2K reputationPosted Feb 5, 2015, 7:18 AM EST
If Student is a class, then it's a reference type or object variable.
If Student is a struct, then it's a value type or value variable.
The term 'object' is not normally used with value types in .NET.
However, the term 'instance' can be applied to either classes or structs so 'abc' could be termed an instance variable in either case.