Java / Local Variables
1. Define local variable.
Local variable also known as block level variable, are identifiers that are declared within a block of code or method. This variable need to be initialized before using it....
2. What is the default value of local variables or method variables?
The local or method level variables are not initialized to any default value, neither primitives nor object references.
3. What is inline value in Java?
Inline value represents the literals in a Java program. For example, String str = "Hello", here the string "Hello" is a inline value.
4. Difference between final and effectively final in Java.
The keyword final ensures that the variable is initialized only once and cannot be altered . Reinitializing would issue compilation errors....
5. Can a local class access the variables from enclosing block in Java?
Yes. From Java 8, local variables are accessible from local class that are final or effectively final .
6. What is synthetic field in Java?
Synthetic fields are compiler generated fields to hold reference to the inner local class which is required by JVM. Synthetic fields are scoped private.