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
Variables declared within a method or block is called Local Variables. These will have limited access.
Variables declared outside of a method or a block called as Members of a class. These can be accessed with the help of object.
Variables preceded with access specifier along with static means class variables. Class variables will be created only one time and accessable with the class name. Only one copy of the variable will be shared across the objects. Source: CoolInterview.com
Answered by: Radha Krishna.L | Date: 9/24/2009
| Contact Radha Krishna.L
1. local means what ever we define with in the method that are called local 2. member is class unit either variable,method(not local variable)may be static or non-static 3. class variable is absolutely static variables for every object of that class share the common variable means it doesn't contribute the object but class Source: CoolInterview.com
Answered by: Narayana swamy | Date: 2/7/2010
| Contact Narayana swamy
Local variable is a variable, which is declared and used with in function or in block.Local variable scope is a particular function or bolck where we declare.
Member variable is a variable which is decalred ouside of the functions or a block available to all functions.by using instance objects these variables can be used in any functions.
Class variable is a variable, whose variable is declared with static keyword.class varibles can be accessed by using Class name. Source: CoolInterview.com
Answered by: G S latha | Date: 4/30/2010
| Contact G S latha
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.
|