What are field variable and local variable?

Answer Posted / ranganathkini

Variables declared outside any method/constructor but inside
the class block, is a field variable.

Variables that are declared within a method or a specific
block of statements are local variables.

Local variables are kept alive as long as the execution is
within the block they're defined in. Once the block is
exited, the local variables can no more be used.

Field variables have longer life than local variables in
that they can live as long as the instance they belong to is
active.

Is This Answer Correct ?    30 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give an example of use of pointers in java class.

556


Can we override final method?

555


How we can skip finally block of exception even if some exception occurs in the exception block in java?

508


what is ststic with example

1585


What is one third plus one third as a fraction?

477






What is the static keyword?

579


What are the two ways of implementing multi-threading in java?

804


Explain how can you debug the Java code?

582


List down the methods and interfaces of collection class in java.

533


What is charat ()?

525


How many JVMs can run on a single machine and what is the Just-In-Time(JIT) compiler?

564


How to sort an array in java without using sort method?

519


Explain public static void main(string args[]) in java.

520


What are the differences between path and classpath variables?

482


How to declare an arraylist in java?

474