What are the possible scope categories for a Java variable?
Advertisements
Question
What are the possible scope categories for a Java variable?
Short Answer
Advertisements
Solution
- Local Variables: These variables are defined within a method, constructor, or block. Their accessibility is limited to that particular method or block.
- Instance Variables: These variables are defined at the class level without the
statickeyword. Each object of the class maintains its own copy of these variables. - Static (Class) Variables: These variables are declared using the
statickeyword within a class. A single copy is shared by all objects of that class.
shaalaa.com
Is there an error in this question or solution?
