What are the different scopes for java variables?

Author Topic: What are the different scopes for java variables?  (Read 811 times)

Offline chinmay.sahooTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 2
  • Posts: 153
  • Karma: 0
    • No Addiction
What are the different scopes for java variables?
« on: 04-02-2016, 04:59:03 »
The different scopes for java variables are as follows:-
  Local
  Instance
  Static


Offline TomClarke

  • Trade Count: (0)
  • Hero Member
  • *****
  • Thank You 17
  • Posts: 897
  • Karma: 0
  • Gender: Male
    • Custom Writing Service & Content Marketplace
Re: What are the different scopes for java variables?
« Reply #1 on: 05-11-2016, 01:38:52 »
Yes, you are right! There are three types of scopes.
1. Instance - these are typical object level variables, they are initialized to default values at the time of creation of object, and remain accessible as long as the object accessible;
2. Local - these are the variables thta are defined within a method. They remain accessible only during the course of method excecution. When the method finishes execution, these variables fall out of scope.
3. Static - these are the class level variables. They are initialized when the class is loaded in JVM for the first time and remain these as long as the class remains loaded. They are not tied to any particular object instance.   
Your ideas, our writings - Writology.com

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
2743 Views
Last post 10-18-2012, 03:21:05
by netedge12
15 Replies
6615 Views
Last post 07-27-2016, 07:41:21
by ShreyaKoushik
3 Replies
3145 Views
Last post 08-19-2015, 01:48:54
by SanviMalhotra
0 Replies
416 Views
Last post 02-15-2016, 03:58:29
by chinmay.sahoo
0 Replies
485 Views
Last post 05-24-2016, 03:07:43
by chinmay.sahoo