Question:
What is a local, member and a class variable?
Answer:
Variables declared within a method are “local” variables. Variables declared within the class i.e not within any methods are “member” variables (global variables). Variables declared within the class i.e not within any methods and are defined as “static” are class variables Source: CoolInterview.com
Variable declared with in the scope of a method called Local Variable.
Variable declared with in the scope of a class but can be accessed only by creating the object of that class called member variable.
Variable declared within the class and are declared as static, can be accessed without creating the instance of that class called class variables. Source: CoolInterview.com
Answered by: Abhishek Singh | Date: 8/28/2009
| Contact Abhishek Singh
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|