What are field variable and local variable?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / monoranjan gorai
Field Variable is a member of a class whereas Local Variable is a member of a method.
Is This Answer Correct ? | 4 Yes | 3 No |
Answer / ravikiran(aptech mumbai)
field variable is the one which can have different access
local variable access restict to method only
Is This Answer Correct ? | 8 Yes | 9 No |
What is string literal in java?
What is the r character?
Is java an open source?
why ,we are using jsp and html.which one is better?
What is method and methodology?
Is the empty set a singleton?
Why singleton pattern is better than creating singleton class with static instance?
what is meant by string pooling?
12 Answers Oracle, Polaris, Tribal Fusion, Wipro,
What is the use of pattern in java?
explain autoboxing in java?
hi to all,i have a question on static block. i saved below as test.java class test extends a { static { System.out.println("test static"); } public static void main(String []dfs) { } } class a { static { System.out.println("a static"); } public static void main(String []asdf) { } } o/p as static test static but if i change base class as test class then class test { static { System.out.println("test static"); } public static void main(String []dfs) { } } class a extends test { static { System.out.println("a static"); } public static void main(String []asdf) { } } o/p test static explain me why "a static" wasn't print in second code when it is in derived class
Is it possible to instantiate the abstract class?