What is the difference between a field variable and a local variable

A field variable is a variable that is declared as a member of a class. A local variable is avariable that isdeclared local to a method.

Showing Answers 1 - 3 of 3 Answers

1.A field variable is a variable which is declared as a member of a class where as a local variable is declared in a method which belongs to a class.
2.Field variables are alive as long as the instance of that class is active.Local variables are alive as long as the block or method is executed.
3.Field can have only ‘static’ access modifier where as the local variables can not have static access modifier.

  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