Differentiate storage classes on the basis of their scope?



Differentiate storage classes on the basis of their scope?..

Answer / Sanjeev Kumar

Storage classes in Java determine the lifetime, visibility, and accessibility of variables. Here's a comparison between their scopes:
1. Variables declared within a method are local variables and have block scope.
2. Static variables have class scope; they exist as long as the class exists.
3. Instance variables (without the static modifier) have instance scope; they exist for each object created from the class.
4. final variables are declared at the field level and have class scope, but their values cannot be changed after assignment.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is java beans?

1 Answers  


Explain the importance of finally over return statement?

1 Answers  


Can we override singleton class?

1 Answers  


Is it safe to install java on my computer?

1 Answers  


What is the difference between array and arraylist? what is the difference between arraylist and linkedlist?

8 Answers   EDS, Matrix,


Explain the selection sort algorithm and state its time complexity?

1 Answers   Flextronics,


How do you escape in java?

1 Answers  


What is identifier in java?

1 Answers  


what is mean by thread lock?

2 Answers   Infosys, TCS,


take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).

1 Answers  


Can we catch more than one exception in single catch block?

1 Answers  


Can an arraylist be empty?

1 Answers  


Categories